{"modulePath":"github.com/noderings/cli","version":"v1.0.19","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package api\n\n## Constants\n\n```go\nconst (\n\tComponentK3s     = \"k3s\"\n\tComponentK3d     = \"k3d\"\n\tComponentCalico  = \"calico\"\n\tComponentLiqo    = \"liqo\"\n\tComponentLiqoctl = \"liqoctl\"\n\tComponentHelm    = \"helm\"\n)\n```\nComponent names returned by MetadataService.GetPlatformVersions.\n\n```go\nconst OrganizationIDHeader = \"X-Organization-ID\"\n```\nOrganizationIDHeader is the gateway tenant header. OAuth sessions bind to the user's home org (often a client org); provider APIs require this header.\n\n```go\nconst ProviderReviewPendingMessage = \"Provider organization review is pending.\"\n```\nProviderReviewPendingMessage 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).\n\n## Functions\n\n```go\nfunc IsProviderReviewPending(err error) bool\n```\nIsProviderReviewPending reports the unverified-provider marketplace lock.\n\n```go\nfunc ParseError(resp *http.Response) error\n```\nParseError 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}}).\n\n## Types\n\n```go\ntype APIError struct {\n\tStatusCode int\n\tMessage    string\n\tDetails    string\n\tCode       string // gRPC error code (e.g., \"NOT_FOUND\", \"ALREADY_EXISTS\")\n}\n```\nAPIError represents an API error from the backend API\n\n```go\nfunc (e *APIError) Error() string\n```\n\n```go\nfunc (e *APIError) IsAlreadyExists() bool\n```\nIsAlreadyExists checks if error is 409 or ALREADY\\_EXISTS\n\n```go\nfunc (e *APIError) IsNotFound() bool\n```\nIsNotFound checks if error is 404\n\n```go\nfunc (e *APIError) IsPermissionDenied() bool\n```\nIsPermissionDenied checks if error is 403 or PERMISSION\\_DENIED\n\n```go\nfunc (e *APIError) IsQuotaExceeded() bool\n```\nIsQuotaExceeded reports plan/entitlement limits (HTTP 429 + quota message). Distinct from transient rate limiting so callers can avoid retrying forever.\n\n```go\nfunc (e *APIError) IsUnauthorized() bool\n```\nIsUnauthorized checks if error is 401\n\n```go\nfunc (e *APIError) UserMessage() string\n```\nUserMessage returns the backend error text when it is more specific than an HTTP status label.\n\n```go\ntype Client struct {\n\t// contains filtered or unexported fields\n}\n```\nClient is the API client wrapper for the platform API It wraps the generated oapi-codegen client with token authentication, retry logic, and error handling\n\n```go\nfunc NewClient(config *Config) (*Client, error)\n```\nNewClient creates a new API client with the generated oapi-codegen client\n\n```go\nfunc (c *Client) DoWithAutoRefresh(ctx context.Context, maxRetries uint, fn func() (*http.Response, error)) (*http.Response, error)\n```\nDoWithAutoRefresh 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\n\n```go\nfunc (c *Client) GetBaseURL() string\n```\nGetBaseURL returns the base URL of the API client\n\n```go\nfunc (c *Client) GetGeneratedClient() *generated.Client\n```\nGetGeneratedClient returns the underlying generated API client (for advanced usage)\n\n```go\nfunc (c *Client) GetOrganizationID() string\n```\nGetOrganizationID returns the tenant UUID sent as X-Organization-ID, if any.\n\n```go\nfunc (c *Client) GetPlatformVersions(ctx context.Context) (*PlatformPins, error)\n```\nGetPlatformVersions fetches the server-pinned install matrix. This endpoint is anonymous; no auth token is required.\n\n```go\nfunc (c *Client) GetPlatformVersionsWithRetry(ctx context.Context, maxRetries uint) (*PlatformPins, error)\n```\nGetPlatformVersionsWithRetry fetches platform versions with retry on transient failures.\n\n```go\nfunc (c *Client) GetToken() string\n```\nGetToken returns the current authentication token\n\n```go\nfunc (c *Client) SetOrganizationID(id string)\n```\nSetOrganizationID sets the tenant sent as X-Organization-ID on every request.\n\n```go\nfunc (c *Client) SetToken(token string)\n```\nSetToken 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.\n\n```go\nfunc (c *Client) SetTokenRefreshFunc(fn TokenRefreshFunc)\n```\nSetTokenRefreshFunc sets the function to call when token needs to be refreshed\n\n```go\nfunc (c *Client) WithRetry(ctx context.Context, maxRetries uint, fn func() error) error\n```\nWithRetry wraps an API call with retry logic using retry-go library It retries on network errors and 5xx status codes with exponential backoff\n\n```go\ntype ComponentPin struct {\n\tName           string\n\tVersion        string\n\tMinVersion     string\n\tDownloadURL    string\n\tChecksumSHA256 string\n}\n```\nComponentPin is a normalized platform component version pin.\n\n```go\ntype Config struct {\n\tBaseURL     string\n\tTimeout     time.Duration\n\tTLSInsecure bool\n\tCACertPath  string\n}\n```\nConfig holds API client configuration\n\n```go\ntype PlatformPins struct {\n\tSchemaVersion string\n\tComponents    map[string]ComponentPin\n}\n```\nPlatformPins is the install matrix keyed by component name.\n\n```go\nfunc ParsePlatformVersions(pv *generated.V1PlatformVersions) (*PlatformPins, error)\n```\nParsePlatformVersions converts a generated V1PlatformVersions into PlatformPins.\n\n```go\nfunc (p *PlatformPins) Get(name string) (ComponentPin, bool)\n```\nGet returns a component pin by name.\n\n```go\nfunc (p *PlatformPins) VersionOr(name, fallback string) string\n```\nVersionOr returns the pinned version for name, or fallback if missing/empty.\n\n```go\ntype TokenRefreshFunc func(ctx context.Context) (string, error)\n```\nTokenRefreshFunc is a function that refreshes an expired token and returns the new token\n\n","path":"github.com/noderings/cli/internal/api","name":"api","synopsis":"","isRedistributable":true}
