Skip to content

Conversation

@SSharma-10
Copy link
Contributor

Implemented GenAI additional Operations:

  • List Available Models
  • List Datacenter Regions

@SSharma-10
Copy link
Contributor Author

SSharma-10 commented Jul 21, 2025

ListAvailableModels Test file

package main

import (
    "context"
    "fmt"
    "log"
    "strings"

    "github.com/digitalocean/godo"
)

func main() {
    token := "DO_TOKEN"
    client := godo.NewFromToken(token)
    ctx := context.TODO()

    // List Available Models
    fmt.Println("=== Listing Available Models ===")
    listAvailableModels(client, ctx)
}

func listAvailableModels(client *godo.Client, ctx context.Context) {
    // Set up list options
    opt := &godo.ListOptions{
        Page:    1,
        PerPage: 10,
    }

    // Call ListAvailableModels
    models, resp, err := client.GenAI.ListAvailableModels(ctx, opt)
    if err != nil {
        log.Fatalf("Error fetching available models: %v", err)
    }

    // Print response info
    fmt.Printf("HTTP Status: %s\n", resp.Status)
    fmt.Printf("Total Models Found: %d\n", len(models))
    fmt.Println(strings.Repeat("-", 50))

    // Print each model
    for i, model := range models {
        fmt.Printf("Model %d:\n", i+1)
        fmt.Printf("  UUID: %s\n", model.Uuid)
        fmt.Printf("  Name: %s\n", model.Name)

        fmt.Printf("  Is Foundational: %t\n", model.IsFoundational)
        fmt.Printf("  Upload Complete: %t\n", model.UploadComplete)

        if model.Provider != "" {
            fmt.Printf("  Provider: %s\n", model.Provider)
        }

        if model.Version != nil {
            fmt.Printf("  Version: %d.%d.%d\n",
                model.Version.Major,
                model.Version.Minor,
                model.Version.Patch)
        }

        if model.Agreement != nil {
            fmt.Printf("  Agreement: %s\n", model.Agreement.Name)
            if model.Agreement.Url != "" {
                fmt.Printf("  Agreement URL: %s\n", model.Agreement.Url)
            }
        }

        if len(model.Usecases) > 0 {
            fmt.Printf("  Use Cases: %v\n", model.Usecases)
        }

        fmt.Println("  " + strings.Repeat("-", 30))
    }

    // Print pagination info if available
    if resp.Links != nil && resp.Links.Pages != nil {
        fmt.Printf("\nPagination Info:\n")
        if resp.Links.Pages.First != "" {
            fmt.Printf("  First: %s\n", resp.Links.Pages.First)
        }
        if resp.Links.Pages.Prev != "" {
            fmt.Printf("  Previous: %s\n", resp.Links.Pages.Prev)
        }
        if resp.Links.Pages.Next != "" {
            fmt.Printf("  Next: %s\n", resp.Links.Pages.Next)
        }
        if resp.Links.Pages.Last != "" {
            fmt.Printf("  Last: %s\n", resp.Links.Pages.Last)
        }
    }

    // Print meta info if available
    if resp.Meta != nil {
        fmt.Printf("\nMeta Info:\n")
        fmt.Printf("  Total: %d\n", resp.Meta.Total)
        fmt.Printf("  Current Page: %d\n", resp.Meta.Page)
        fmt.Printf("  Total Pages: %d\n", resp.Meta.Pages)
    }
}```


**ListDatacenterRegions Test file**

```go
func main() {
    token := "DO_TOKEN"
    client := godo.NewFromToken(token)
    ctx := context.TODO()

    // List Datacenter Regions
    fmt.Println("=== Listing Datacenter Regions ===")
    listDatacenterRegions(client, ctx)
}

func listDatacenterRegions(client *godo.Client, ctx context.Context) {
    // Call ListDatacenterRegions
    regions, resp, err := client.GenAI.ListDatacenterRegions(ctx)
    if err != nil {
        log.Fatalf("Error fetching datacenter regions: %v", err)
    }

    // Print response info
    fmt.Printf("HTTP Status: %s\n", resp.Status)
    fmt.Printf("Total Regions Found: %d\n", len(regions))
    fmt.Println(strings.Repeat("-", 50))

    // Print each region
    for i, region := range regions {
        fmt.Printf("Region %d:\n", i+1)
        fmt.Printf("  Region: %s\n", region.Region)
        fmt.Printf("  Inference URL: %s\n", region.InferenceUrl)
        fmt.Printf("  Serves Batch: %t\n", region.ServesBatch)
        fmt.Printf("  Serves Inference: %t\n", region.ServesInference)
        fmt.Printf("  Stream Inference URL: %s\n", region.StreamInferenceUrl)
        fmt.Println("  " + strings.Repeat("-", 30))
    }

    // Print response status
    fmt.Printf("\nResponse Status Code: %d\n", resp.StatusCode)
}```

m3co-code and others added 8 commits August 4, 2025 13:13
…version (#883)

* Add GitHub Actions workflow to generate CHANGELOG.md and update libraryVersion

* correct version check

* version to run

* Fix missing newline at end of file in update-release-info.yml

* fix hard coded version

* Update libraryVersion in godo.go to use dynamic version input

* Release 1.160.1: update CHANGELOG and libraryVersion

* Timetravel

* Update CHANGELOG.md

* Release 1.160.2: update CHANGELOG and libraryVersion

* Release 1.160.3: update CHANGELOG and libraryVersion

* Update 1-click_test.go

* Update README.md

* Update CHANGELOG.md

* manual time change

* Release 1.160.4: update CHANGELOG and libraryVersion

* Release 1.160.5: update CHANGELOG and libraryVersion

* Update CONTRIBUTING.md

* Update update-release-info.yml

* Update 1-click_test.go

* Update godo.go

* Update README.md

* Update CHANGELOG.md

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

@harshmaru7 harshmaru7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀 🎸

@harshmaru7 harshmaru7 merged commit 3713f18 into main Aug 4, 2025
9 checks passed
@harshmaru7 harshmaru7 deleted the GenAI_Additional_Operations branch August 4, 2025 15:51
@SSharma-10 SSharma-10 mentioned this pull request Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants