Go SDK

View as Markdown

The nvfleetint package provides a handwritten Go client for the Fleet Intelligence customer API.

Install

$go get github.com/NVIDIA/fleet-intelligence-client/nvfleetint

Use the Go version declared in the repository’s go.mod file or newer.

Create a client

1package main
2
3import (
4 "context"
5 "fmt"
6 "log"
7 "os"
8
9 "github.com/NVIDIA/fleet-intelligence-client/nvfleetint"
10)
11
12func main() {
13 client, err := nvfleetint.NewClient(
14 "https://api.fleet-intelligence.nvidia.com",
15 os.Getenv("NVFLEETINT_API_KEY"),
16 )
17 if err != nil {
18 log.Fatal(err)
19 }
20
21 page, err := client.ListNodes(context.Background(), nvfleetint.ListNodesOptions{})
22 if err != nil {
23 log.Fatal(err)
24 }
25
26 for _, node := range page.Nodes {
27 fmt.Printf("%s\t%s\n", node.UUID, node.Hostname)
28 }
29}

NewClient requires an HTTPS API URL and an API key. Plain HTTP is accepted only for loopback addresses used during local development.

The default per-request timeout is two minutes. Override it when constructing the client:

1client, err := nvfleetint.NewClient(
2 apiURL,
3 apiKey,
4 nvfleetint.WithTimeout(30*time.Second),
5)

Public SDK types and methods are documented in the package source under nvfleetint.

Alert timeline filter values and sorting choices are available through GetAlertTimelineFilterOptions. Pass true for the active-alert view or false for the historical view:

1options, err := client.GetAlertTimelineFilterOptions(ctx, true)