criblcloudmanagementsdkgo

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

README

cribl-cloud-management-sdk-go

The Cribl Go SDK for the management plane provides operational control of administrative tasks like configuring and managing Workspaces and helps streamline the process of integrating with Cribl.

The Cribl Go SDK for the management plane is supported only on Cribl.Cloud.

Complementary API reference documentation is available at https://docs.cribl.io/cribl-as-code/api-reference/management-plane/. Product documentation is available at https://docs.cribl.io.

[!IMPORTANT] Cribl has stopped active development of the Go SDK for the management plane. The SDK will remain an open-source, community resource on the Cribl Community GitHub organization. You can continue using the Go SDK and build on it, but Cribl support will be limited to critical issues only for the defined transition period. Support will end on October 1, 2026. If you prefer to stay on a supported integration, consider migrating to the Python SDK, Terraform provider, or direct Cribl API access.

Table of Contents

SDK Installation

To add the SDK as a dependency to your project:

go get github.com/Cribl-Community/cribl-cloud-management-sdk-go

SDK Example Usage

Example
package main

import (
	"context"
	criblcloudmanagementsdkgo "github.com/Cribl-Community/cribl-cloud-management-sdk-go"
	"github.com/Cribl-Community/cribl-cloud-management-sdk-go/models/components"
	"log"
	"os"
)

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

	s := criblcloudmanagementsdkgo.New(
		criblcloudmanagementsdkgo.WithSecurity(components.Security{
			ClientOauth: &components.SchemeClientOauth{
				ClientID:     os.Getenv("CRIBLMGMTPLANE_CLIENT_ID"),
				ClientSecret: os.Getenv("CRIBLMGMTPLANE_CLIENT_SECRET"),
				TokenURL:     os.Getenv("CRIBLMGMTPLANE_TOKEN_URL"),
				Audience:     "https://api.cribl.cloud",
			},
		}),
	)

	res, err := s.Health.Get(ctx)
	if err != nil {
		log.Fatal(err)
	}
	if res.Object != nil {
		// handle response
	}
}

Authentication

All Cribl management plane SDK requests require you to authenticate with a Bearer token. The Bearer token verifies your identity and ensures secure access to the requested resources. The SDK uses the OAuth2 credentials you provide when initializing your SDK client to obtain the Bearer token. The SDK automatically manages the Authorization header for subsequent requests once properly authenticated.

For information about Bearer token expiration, see Token Management in the Cribl as Code documentation.

Authentication happens once during SDK initialization. After you initialize the SDK client with authentication as shown in the authentication example, the SDK automatically handles authentication for all subsequent API calls. You do not need to include authentication parameters in individual API requests. The SDK Example Usage section shows how to initialize the SDK and make API calls, but if you've properly initialized your client as shown in the authentication example, you only need to make the API method calls themselves without re-initializing.

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme Environment Variable
ClientOauth oauth2 OAuth2 token CRIBLMGMTPLANE_CLIENT_OAUTH

Set the security scheme through the security parameter when initializing the SDK client instance. The SDK uses the OAuth2 credentials that you provide for the ClientOauth scheme to obtain a Bearer token, refresh the token within its expiration window using the standard OAuth2 flow, and authenticate with the API.

Authentication Example

The Cribl.Cloud Authentication Example demonstrates how to configure authentication on Cribl.Cloud and in hybrid deployments. To obtain the Client ID and Client Secret you'll need to initialize using the ClientOauth security schema, follow the instructions for creating an API Credential in the Cribl as Code documentation.

Available Resources and Operations

Available methods
ApiCredentials
  • List - List API Credentials for an Organization
  • Create - Create an API Credential
  • Update - Update an API Credential
  • Delete - Delete an API Credential
  • Get - Get an API Credential
Health
  • Get - Get the health status of the application
Workspaces
  • Create - Create a Workspace in the specified Organization
  • List - List all Workspaces for the specified Organization
  • Update - Update a Workspace
  • Delete - Delete a Workspace
  • Get - Get a Workspace

Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide a retry.Config object to the call by using the WithRetries option:

package main

import (
	"context"
	criblcloudmanagementsdkgo "github.com/Cribl-Community/cribl-cloud-management-sdk-go"
	"github.com/Cribl-Community/cribl-cloud-management-sdk-go/models/components"
	"github.com/Cribl-Community/cribl-cloud-management-sdk-go/retry"
	"log"
	"models/operations"
	"os"
)

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

	s := criblcloudmanagementsdkgo.New(
		criblcloudmanagementsdkgo.WithSecurity(components.Security{
			ClientOauth: &components.SchemeClientOauth{
				ClientID:     os.Getenv("CRIBLMGMTPLANE_CLIENT_ID"),
				ClientSecret: os.Getenv("CRIBLMGMTPLANE_CLIENT_SECRET"),
				TokenURL:     os.Getenv("CRIBLMGMTPLANE_TOKEN_URL"),
				Audience:     "https://api.cribl.cloud",
			},
		}),
	)

	res, err := s.Health.Get(ctx, operations.WithRetries(
		retry.Config{
			Strategy: "backoff",
			Backoff: &retry.BackoffStrategy{
				InitialInterval: 1,
				MaxInterval:     50,
				Exponent:        1.1,
				MaxElapsedTime:  100,
			},
			RetryConnectionErrors: false,
		}))
	if err != nil {
		log.Fatal(err)
	}
	if res.Object != nil {
		// handle response
	}
}

If you'd like to override the default retry strategy for all operations that support retries, you can use the WithRetryConfig option at SDK initialization:

package main

import (
	"context"
	criblcloudmanagementsdkgo "github.com/Cribl-Community/cribl-cloud-management-sdk-go"
	"github.com/Cribl-Community/cribl-cloud-management-sdk-go/models/components"
	"github.com/Cribl-Community/cribl-cloud-management-sdk-go/retry"
	"log"
	"os"
)

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

	s := criblcloudmanagementsdkgo.New(
		criblcloudmanagementsdkgo.WithRetryConfig(
			retry.Config{
				Strategy: "backoff",
				Backoff: &retry.BackoffStrategy{
					InitialInterval: 1,
					MaxInterval:     50,
					Exponent:        1.1,
					MaxElapsedTime:  100,
				},
				RetryConnectionErrors: false,
			}),
		criblcloudmanagementsdkgo.WithSecurity(components.Security{
			ClientOauth: &components.SchemeClientOauth{
				ClientID:     os.Getenv("CRIBLMGMTPLANE_CLIENT_ID"),
				ClientSecret: os.Getenv("CRIBLMGMTPLANE_CLIENT_SECRET"),
				TokenURL:     os.Getenv("CRIBLMGMTPLANE_TOKEN_URL"),
				Audience:     "https://api.cribl.cloud",
			},
		}),
	)

	res, err := s.Health.Get(ctx)
	if err != nil {
		log.Fatal(err)
	}
	if res.Object != nil {
		// handle response
	}
}

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both.

By Default, an API error will return apierrors.APIError. When custom error responses are specified for an operation, the SDK may also return their associated error. You can refer to respective Errors tables in SDK docs for more details on possible error types for each operation.

For example, the Create function may return the following errors:

Error Type Status Code Content Type
apierrors.DefaultErrorDTO 422 application/json
apierrors.APIError 4XX, 5XX */*
Example
package main

import (
	"context"
	"errors"
	criblcloudmanagementsdkgo "github.com/Cribl-Community/cribl-cloud-management-sdk-go"
	"github.com/Cribl-Community/cribl-cloud-management-sdk-go/models/apierrors"
	"github.com/Cribl-Community/cribl-cloud-management-sdk-go/models/components"
	"log"
	"os"
)

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

	s := criblcloudmanagementsdkgo.New(
		criblcloudmanagementsdkgo.WithSecurity(components.Security{
			ClientOauth: &components.SchemeClientOauth{
				ClientID:     os.Getenv("CRIBLMGMTPLANE_CLIENT_ID"),
				ClientSecret: os.Getenv("CRIBLMGMTPLANE_CLIENT_SECRET"),
				TokenURL:     os.Getenv("CRIBLMGMTPLANE_TOKEN_URL"),
				Audience:     "https://api.cribl.cloud",
			},
		}),
	)

	res, err := s.APICredentials.Create(ctx, "<id>", components.APICredentialCreateRequestDTO{
		Name:        "Auto-Manage-Workspaces",
		Description: "Used for automated Workspace management",
		Enabled:     true,
		Roles: components.APICredentialRolesSchema{
			OrganizationRole: components.OrganizationRoleAdmin,
			Workspaces: []components.WorkspaceRoleSchema{
				components.WorkspaceRoleSchema{
					WorkspaceID:   "main",
					WorkspaceRole: components.WorkspaceRoleAdmin,
					Products: []components.ProductRoleSchema{
						components.ProductRoleSchema{
							Product: components.ProductStream,
							Role:    components.RoleAdmin,
						},
					},
				},
			},
		},
		IPAllowlist: []string{
			"10.0.0.1/32",
		},
	})
	if err != nil {

		var e *apierrors.DefaultErrorDTO
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}

		var e *apierrors.APIError
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}
	}
}

Server Selection

Override Server URL Per-Client

The default server can be overridden globally using the WithServerURL(serverURL string) option when initializing the SDK client instance. For example:

package main

import (
	"context"
	criblcloudmanagementsdkgo "github.com/Cribl-Community/cribl-cloud-management-sdk-go"
	"github.com/Cribl-Community/cribl-cloud-management-sdk-go/models/components"
	"log"
	"os"
)

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

	s := criblcloudmanagementsdkgo.New(
		criblcloudmanagementsdkgo.WithServerURL("https://gateway.cribl.cloud"),
		criblcloudmanagementsdkgo.WithSecurity(components.Security{
			ClientOauth: &components.SchemeClientOauth{
				ClientID:     os.Getenv("CRIBLMGMTPLANE_CLIENT_ID"),
				ClientSecret: os.Getenv("CRIBLMGMTPLANE_CLIENT_SECRET"),
				TokenURL:     os.Getenv("CRIBLMGMTPLANE_TOKEN_URL"),
				Audience:     "https://api.cribl.cloud",
			},
		}),
	)

	res, err := s.Health.Get(ctx)
	if err != nil {
		log.Fatal(err)
	}
	if res.Object != nil {
		// handle response
	}
}

Custom HTTP Client

The Go SDK makes API calls that wrap an internal HTTP client. The requirements for the HTTP client are very simple. It must match this interface:

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

The built-in net/http client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout.

import (
	"net/http"
	"time"

	"github.com/Cribl-Community/cribl-cloud-management-sdk-go"
)

var (
	httpClient = &http.Client{Timeout: 30 * time.Second}
	sdkClient  = criblcloudmanagementsdkgo.New(criblcloudmanagementsdkgo.WithClient(httpClient))
)

This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServerList = []string{
	"https://gateway.cribl.cloud",
}

ServerList contains the list of servers available to the SDK

Functions

func Bool

func Bool(b bool) *bool

Bool provides a helper function to return a pointer to a bool

func Float32

func Float32(f float32) *float32

Float32 provides a helper function to return a pointer to a float32

func Float64

func Float64(f float64) *float64

Float64 provides a helper function to return a pointer to a float64

func Int

func Int(i int) *int

Int provides a helper function to return a pointer to an int

func Int64

func Int64(i int64) *int64

Int64 provides a helper function to return a pointer to an int64

func Pointer

func Pointer[T any](v T) *T

Pointer provides a helper function to return a pointer to a type

func String

func String(s string) *string

String provides a helper function to return a pointer to a string

Types

type APICredentials

type APICredentials struct {
	// contains filtered or unexported fields
}

APICredentials - Operations related to API credentials

func (*APICredentials) Create

Create an API Credential Create a new API Credential for the specified Organization.

func (*APICredentials) Delete

func (s *APICredentials) Delete(ctx context.Context, organizationID string, apiCredentialID string, opts ...operations.Option) (*operations.V1APICredentialsDeleteAPICredentialResponse, error)

Delete an API Credential Delete the specified API Credential.

func (*APICredentials) Get

func (s *APICredentials) Get(ctx context.Context, organizationID string, apiCredentialID string, opts ...operations.Option) (*operations.V1APICredentialsGetAPICredentialResponse, error)

Get an API Credential Get the specified API Credential.

func (*APICredentials) List

List API Credentials for an Organization Get a list of all API Credentials for the specified Organization.

func (*APICredentials) Update

func (s *APICredentials) Update(ctx context.Context, organizationID string, apiCredentialID string, apiCredentialUpdateRequestDTO components.APICredentialUpdateRequestDTO, opts ...operations.Option) (*operations.V1APICredentialsUpdateAPICredentialResponse, error)

Update an API Credential Update the specified API Credential.

type CriblMgmtPlane

type CriblMgmtPlane struct {
	SDKVersion string
	// Operations related to application health status
	Health *Health
	// Operations related to API credentials
	APICredentials *APICredentials
	// Operations related to Workspaces
	Workspaces *Workspaces
	// contains filtered or unexported fields
}

CriblMgmtPlane - Cribl.Cloud Public API: Public API for the Cribl.Cloud platform. Powers the Speakeasy SDK.

func New

func New(opts ...SDKOption) *CriblMgmtPlane

New creates a new instance of the SDK with the provided options

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient provides an interface for supplying the SDK with a custom HTTP client

type Health

type Health struct {
	// contains filtered or unexported fields
}

Health - Operations related to application health status

func (*Health) Get

Get the health status of the application

type SDKOption

type SDKOption func(*CriblMgmtPlane)

func WithClient

func WithClient(client HTTPClient) SDKOption

WithClient allows the overriding of the default HTTP client used by the SDK

func WithRetryConfig

func WithRetryConfig(retryConfig retry.Config) SDKOption

func WithSecurity

func WithSecurity(security components.Security) SDKOption

WithSecurity configures the SDK to use the provided security details

func WithSecuritySource

func WithSecuritySource(security func(context.Context) (components.Security, error)) SDKOption

WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication

func WithServerIndex

func WithServerIndex(serverIndex int) SDKOption

WithServerIndex allows the overriding of the default server by index

func WithServerURL

func WithServerURL(serverURL string) SDKOption

WithServerURL allows providing an alternative server URL

func WithTemplatedServerURL

func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption

WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters

func WithTimeout

func WithTimeout(timeout time.Duration) SDKOption

WithTimeout Optional request timeout applied to each operation

type Workspaces

type Workspaces struct {
	// contains filtered or unexported fields
}

Workspaces - Operations related to Workspaces

func (*Workspaces) Create

func (s *Workspaces) Create(ctx context.Context, organizationID string, workspaceCreateRequestDTO components.WorkspaceCreateRequestDTO, opts ...operations.Option) (*operations.V1WorkspacesCreateWorkspaceResponse, error)

Create a Workspace in the specified Organization Create a new Workspace in the specified Organization.

func (*Workspaces) Delete

func (s *Workspaces) Delete(ctx context.Context, organizationID string, workspaceID string, opts ...operations.Option) (*operations.V1WorkspacesDeleteWorkspaceResponse, error)

Delete a Workspace Delete the specified Workspace in the specified Organization.

func (*Workspaces) Get

func (s *Workspaces) Get(ctx context.Context, organizationID string, workspaceID string, opts ...operations.Option) (*operations.V1WorkspacesGetWorkspaceResponse, error)

Get a Workspace Get the specified Workspace.

func (*Workspaces) List

List all Workspaces for the specified Organization Get a list of all Workspaces for the specified Organization.

func (*Workspaces) Update

func (s *Workspaces) Update(ctx context.Context, organizationID string, workspaceID string, workspacePatchRequestDTO components.WorkspacePatchRequestDTO, opts ...operations.Option) (*operations.V1WorkspacesUpdateWorkspaceResponse, error)

Update a Workspace Update the specified Workspace.

Directories

Path Synopsis
internal
models

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL