This is the Go API Client for Bonsai Cloud - The only managed Elasticsearch, OpenSearch, and SolrCloud platform that provides the support of a search engineering team, but at a fraction of the cost!
Full documentation is available on godoc at https://pkg.go.dev/github.com/omc/bonsai-api-go/v2/bonsai/
- Install godoc
go install golang.org/x/tools/cmd/godoc@latest
- Run
godoc
from the project's root directory:godoc -http:6060
go get github.com/omc/bonsai-api-go/v2/bonsai
package main
import (
"context"
"log"
"os"
"github.com/omc/bonsai-api-go/v2/bonsai"
)
func main() {
// Fetch API Key and Token from environment variables
apiKey := os.Getenv("BONSAI_API_KEY")
apiToken := os.Getenv("BONSAI_API_TOKEN")
// Create a new Bonsai API Client
client := bonsai.NewClient(
bonsai.WithCredentialPair(
bonsai.CredentialPair{
AccessKey: bonsai.AccessKey(apiKey),
AccessToken: bonsai.AccessToken(apiToken),
},
),
)
// Fetch all of our clusters
clusters, err := client.Cluster.All(context.Background())
if err != nil {
log.Fatalf("error listing clusters: %s\n", err)
}
log.Printf("Found %d clusters! Details: %v\n", len(clusters), clusters)
}