Skip to content

docs: Add Go code samples for fleet management API #4371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 51 additions & 6 deletions docs/dev/reference/apis/fleet.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ With it you can
- manage permissions and authorization
- create and manage fragments

{{% alert title="Support Notice" color="note" %}}

Fleet management API methods are only available in the Python SDK.

{{% /alert %}}

The fleet management API supports the following methods:

{{< readfile "/static/include/app/apis/generated/app-table.md" >}}
Expand Down Expand Up @@ -91,6 +85,57 @@ if __name__ == '__main__':
asyncio.run(main())
```

{{% /tab %}}
{{% tab name="Go" %}}

```go {class="line-numbers linkable-line-numbers"}
package main

import (
"context"
"log"

"go.viam.com/rdk/app"
"go.viam.com/rdk/logging"
"go.viam.com/utils"
)

func main() {
logger := logging.NewLogger("fleet-management")

// Replace "<API-KEY-ID>" (including brackets) with your API key ID
apiKeyID := "<API-KEY-ID>"
// Replace "<API-KEY>" (including brackets) with your API key
apiKey := "<API-KEY>"

client, err := app.NewAppClient(context.Background(), app.Config{
BaseURL: "https://app.viam.com:443",
Auth: utils.Credentials{
Type: utils.CredentialsTypeAPIKey,
Payload: apiKey,
},
AuthEntity: &apiKeyID,
Logger: logger,
})
if err != nil {
log.Fatalf("Failed to create app client: %v", err)
}
defer client.Close()

// Use the client to make fleet management API calls
// Example: List organizations
ctx := context.Background()
orgs, err := client.ListOrganizations(ctx)
if err != nil {
log.Fatalf("Failed to list organizations: %v", err)
}

for _, org := range orgs {
log.Printf("Organization: %s (ID: %s)", org.Name, org.Id)
}
}
```

{{% /tab %}}
{{% tab name="TypeScript" %}}

Expand Down
Loading
Loading