api

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ComponentK3s     = "k3s"
	ComponentK3d     = "k3d"
	ComponentCalico  = "calico"
	ComponentLiqo    = "liqo"
	ComponentLiqoctl = "liqoctl"
	ComponentHelm    = "helm"
)

Component names returned by MetadataService.GetPlatformVersions.

View Source
const OrganizationIDHeader = "X-Organization-ID"

OrganizationIDHeader is the gateway tenant header. OAuth sessions bind to the user's home org (often a client org); provider APIs require this header.

View Source
const ProviderReviewPendingMessage = "Provider organization review is pending."

ProviderReviewPendingMessage is the backend PermissionDenied copy for an unverified provider organization. CLI commands that hit blocked provider APIs must surface this string to the user (not a generic 403).

Variables

This section is empty.

Functions

func IsProviderReviewPending

func IsProviderReviewPending(err error) bool

IsProviderReviewPending reports the unverified-provider marketplace lock.

func ParseError

func ParseError(resp *http.Response) error

ParseError parses an HTTP error response from the backend API. The gateway emits google.rpc.Status JSON (code/message/details) and sometimes a nested camelCase error object ({error:{message,status}}).

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
	Details    string
	Code       string // gRPC error code (e.g., "NOT_FOUND", "ALREADY_EXISTS")
}

APIError represents an API error from the backend API

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) IsAlreadyExists

func (e *APIError) IsAlreadyExists() bool

IsAlreadyExists checks if error is 409 or ALREADY_EXISTS

func (*APIError) IsNotFound

func (e *APIError) IsNotFound() bool

IsNotFound checks if error is 404

func (*APIError) IsPermissionDenied

func (e *APIError) IsPermissionDenied() bool

IsPermissionDenied checks if error is 403 or PERMISSION_DENIED

func (*APIError) IsQuotaExceeded

func (e *APIError) IsQuotaExceeded() bool

IsQuotaExceeded reports plan/entitlement limits (HTTP 429 + quota message). Distinct from transient rate limiting so callers can avoid retrying forever.

func (*APIError) IsUnauthorized

func (e *APIError) IsUnauthorized() bool

IsUnauthorized checks if error is 401

func (*APIError) UserMessage

func (e *APIError) UserMessage() string

UserMessage returns the backend error text when it is more specific than an HTTP status label.

type Client

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

Client is the API client wrapper for the platform API It wraps the generated oapi-codegen client with token authentication, retry logic, and error handling

func NewClient

func NewClient(config *Config) (*Client, error)

NewClient creates a new API client with the generated oapi-codegen client

func (*Client) DoWithAutoRefresh

func (c *Client) DoWithAutoRefresh(ctx context.Context, maxRetries uint, fn func() (*http.Response, error)) (*http.Response, error)

DoWithAutoRefresh executes an API call function and automatically refreshes token on 401 It wraps the call with retry logic and handles 401 by refreshing the token once

func (*Client) GetBaseURL

func (c *Client) GetBaseURL() string

GetBaseURL returns the base URL of the API client

func (*Client) GetGeneratedClient

func (c *Client) GetGeneratedClient() *generated.Client

GetGeneratedClient returns the underlying generated API client (for advanced usage)

func (*Client) GetOrganizationID added in v1.0.1

func (c *Client) GetOrganizationID() string

GetOrganizationID returns the tenant UUID sent as X-Organization-ID, if any.

func (*Client) GetPlatformVersions

func (c *Client) GetPlatformVersions(ctx context.Context) (*PlatformPins, error)

GetPlatformVersions fetches the server-pinned install matrix. This endpoint is anonymous; no auth token is required.

func (*Client) GetPlatformVersionsWithRetry

func (c *Client) GetPlatformVersionsWithRetry(ctx context.Context, maxRetries uint) (*PlatformPins, error)

GetPlatformVersionsWithRetry fetches platform versions with retry on transient failures.

func (*Client) GetToken

func (c *Client) GetToken() string

GetToken returns the current authentication token

func (*Client) SetOrganizationID added in v1.0.1

func (c *Client) SetOrganizationID(id string)

SetOrganizationID sets the tenant sent as X-Organization-ID on every request.

func (*Client) SetToken

func (c *Client) SetToken(token string)

SetToken sets the authentication token used by every request. The request editor is installed once and reads the current token per request, so refreshing a token never mutates the editor slice while requests are in flight.

func (*Client) SetTokenRefreshFunc

func (c *Client) SetTokenRefreshFunc(fn TokenRefreshFunc)

SetTokenRefreshFunc sets the function to call when token needs to be refreshed

func (*Client) WithRetry

func (c *Client) WithRetry(ctx context.Context, maxRetries uint, fn func() error) error

WithRetry wraps an API call with retry logic using retry-go library It retries on network errors and 5xx status codes with exponential backoff

type ComponentPin

type ComponentPin struct {
	Name           string
	Version        string
	MinVersion     string
	DownloadURL    string
	ChecksumSHA256 string
}

ComponentPin is a normalized platform component version pin.

type Config

type Config struct {
	BaseURL     string
	Timeout     time.Duration
	TLSInsecure bool
	CACertPath  string
}

Config holds API client configuration

type PlatformPins

type PlatformPins struct {
	SchemaVersion string
	Components    map[string]ComponentPin
}

PlatformPins is the install matrix keyed by component name.

func ParsePlatformVersions

func ParsePlatformVersions(pv *generated.V1PlatformVersions) (*PlatformPins, error)

ParsePlatformVersions converts a generated V1PlatformVersions into PlatformPins.

func (*PlatformPins) Get

func (p *PlatformPins) Get(name string) (ComponentPin, bool)

Get returns a component pin by name.

func (*PlatformPins) VersionOr

func (p *PlatformPins) VersionOr(name, fallback string) string

VersionOr returns the pinned version for name, or fallback if missing/empty.

type TokenRefreshFunc

type TokenRefreshFunc func(ctx context.Context) (string, error)

TokenRefreshFunc is a function that refreshes an expired token and returns the new token

Directories

Path Synopsis
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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