Skip to main content

Go SDK

The Okustera Go SDK provides idiomatic, high-performance Go packages to interact with the Okustera Cloud API.

It powers the official Okustera Terraform Provider and custom automation controllers.


Installation​

go get github.com/okustera/okustera-sdk-go

Example Usage​

package main

import (
"context"
"fmt"
"log"
"os"

"github.com/okustera/okustera-sdk-go/client"
)

func main() {
ctx := context.Background()

// Initialize the API client
c, err := client.NewClient(client.Config{
Endpoint: "https://portal.okustera.com/api/v1",
APIToken: os.Getenv("OKUSTERA_API_TOKEN"),
TenantID: "tenant-production",
})
if err != nil {
log.Fatalf("failed to create client: %v", err)
}

// Create a high-availability PostgreSQL database
db, err := c.CreatePostgresCluster(ctx, client.DatabaseClusterCreate{
Name: "inventory-db",
Namespace: "default",
Replicas: 3,
StorageSize: "100Gi",
DatabaseName: "inventory",
})
if err != nil {
log.Fatalf("failed to create database: %v", err)
}

fmt.Printf("Database %s provisioned successfully (Status: %s, Endpoint: %s)\n", db.Name, db.Status, db.ServiceEndpoint)
}