api

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package api is the HTTP client for the Volcano cloud API.

Index

Constants

View Source
const (

	// DefaultPage is the first page fetched by paginated API callers.
	DefaultPage = 1
	// DefaultLimit is the default number of resources fetched per page.
	DefaultLimit = 100
)

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned by resolver lookups when no matching resource exists. Callers branch on it with errors.Is(err, api.ErrNotFound).

Functions

func Status

func Status(err error) int

Status returns the HTTP status code carried by an *Error wrapped in err, or 0 if err is nil or does not wrap an *Error.

Types

type Client

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

Client is a thin wrapper around the generated OpenAPI client.

func NewClient

func NewClient(apiURL, token string, opts ...Option) (*Client, error)

NewClient constructs a generated client with auth and error-normalization helpers.

func (*Client) CopyStorageObject

func (c *Client) CopyStorageObject(ctx context.Context, bucketName, from, to string) (*apiclient.StorageObject, error)

CopyStorageObject copies one object within a bucket.

func (*Client) CreateDatabase

func (c *Client) CreateDatabase(ctx context.Context, projectID uuid.UUID, name, region, pgVersion, databaseType string) (*apiclient.Database, error)

CreateDatabase creates a database in a project.

func (*Client) CreateFrontendCustomDomain

func (c *Client) CreateFrontendCustomDomain(ctx context.Context, projectID, frontendID uuid.UUID, input FrontendCustomDomainInput) (*apiclient.FrontendCustomDomainResponse, error)

CreateFrontendCustomDomain attaches a BYOC custom domain to a frontend.

func (*Client) CreateFunctionScheduler

func (c *Client) CreateFunctionScheduler(ctx context.Context, projectID, functionID uuid.UUID, input FunctionSchedulerInput) (*apiclient.FunctionScheduler, error)

CreateFunctionScheduler creates one scheduler for a function.

func (*Client) CreateProject

func (c *Client) CreateProject(ctx context.Context, name string) (*apiclient.Project, error)

CreateProject creates a project for the authenticated user.

func (*Client) CreateStorageBucket

func (c *Client) CreateStorageBucket(ctx context.Context, projectID uuid.UUID, input StorageBucketCreateInput) (*apiclient.StorageBucket, error)

CreateStorageBucket creates one bucket in the project.

func (*Client) CreateStoragePolicy

func (c *Client) CreateStoragePolicy(ctx context.Context, projectID uuid.UUID, bucketName string, input StoragePolicyCreateInput) (*apiclient.StoragePolicy, error)

CreateStoragePolicy attaches a new policy to a bucket.

func (*Client) CreateVariable

func (c *Client) CreateVariable(ctx context.Context, projectID uuid.UUID, name, value string) (*apiclient.Variable, error)

CreateVariable creates a variable in a project.

func (*Client) DeleteDatabase

func (c *Client) DeleteDatabase(ctx context.Context, projectID uuid.UUID, databaseName string) error

DeleteDatabase deletes one database by name.

func (*Client) DeleteFrontend

func (c *Client) DeleteFrontend(ctx context.Context, projectID, frontendID uuid.UUID) error

DeleteFrontend starts deleting one frontend by ID.

func (*Client) DeleteFrontendCustomDomain

func (c *Client) DeleteFrontendCustomDomain(ctx context.Context, projectID, frontendID uuid.UUID) error

DeleteFrontendCustomDomain detaches the configured custom domain from a frontend.

func (*Client) DeleteFunction

func (c *Client) DeleteFunction(ctx context.Context, projectID, functionID uuid.UUID) error

DeleteFunction starts deleting one function by ID.

func (*Client) DeleteFunctionScheduler

func (c *Client) DeleteFunctionScheduler(ctx context.Context, projectID, functionID, schedulerID uuid.UUID) error

DeleteFunctionScheduler deletes one scheduler for a function.

func (*Client) DeleteProject

func (c *Client) DeleteProject(ctx context.Context, projectID uuid.UUID) error

DeleteProject starts project deletion.

func (*Client) DeleteStorageBucket

func (c *Client) DeleteStorageBucket(ctx context.Context, projectID uuid.UUID, bucketName string) error

DeleteStorageBucket removes one bucket from the project.

func (*Client) DeleteStorageObject

func (c *Client) DeleteStorageObject(ctx context.Context, bucketName, path string) error

DeleteStorageObject removes one object from a bucket.

func (*Client) DeleteStoragePolicy

func (c *Client) DeleteStoragePolicy(ctx context.Context, projectID uuid.UUID, bucketName string, policyID uuid.UUID) error

DeleteStoragePolicy removes one policy from a bucket.

func (*Client) DeleteVariable

func (c *Client) DeleteVariable(ctx context.Context, projectID uuid.UUID, name string) error

DeleteVariable deletes one variable by name.

func (*Client) DeployFrontend

func (c *Client) DeployFrontend(ctx context.Context, projectID uuid.UUID, input FrontendDeployInput) (*apiclient.Frontend, error)

DeployFrontend uploads one frontend source archive.

func (*Client) DeployFunction

func (c *Client) DeployFunction(ctx context.Context, projectID uuid.UUID, fn FunctionDeployInput) (*apiclient.Function, error)

DeployFunction deploys one function source archive.

func (*Client) DeployFunctionsBatch

func (c *Client) DeployFunctionsBatch(ctx context.Context, projectID uuid.UUID, functions []FunctionDeployInput) (*apiclient.BatchFunctionDeployResponse, error)

DeployFunctionsBatch deploys one batch of function source archives.

func (*Client) DownloadStorageObject

func (c *Client) DownloadStorageObject(ctx context.Context, bucketName, path string) (*http.Response, error)

DownloadStorageObject opens a streaming download for one object. The caller is responsible for closing the response body.

func (*Client) ExchangePlatformToken

func (c *Client) ExchangePlatformToken(ctx context.Context, authAccessToken, clientID string) (*apiclient.PlatformExchangeResponse, error)

ExchangePlatformToken exchanges an auth-user device-flow token for a platform token.

func (*Client) GetDatabase

func (c *Client) GetDatabase(ctx context.Context, projectID uuid.UUID, databaseName string) (*apiclient.Database, error)

GetDatabase returns one database by name.

func (*Client) GetFrontend

func (c *Client) GetFrontend(ctx context.Context, projectID, frontendID uuid.UUID) (*apiclient.Frontend, error)

GetFrontend returns one frontend by ID.

func (*Client) GetFrontendCustomDomain

func (c *Client) GetFrontendCustomDomain(ctx context.Context, projectID, frontendID uuid.UUID) (*apiclient.FrontendCustomDomainResponse, error)

GetFrontendCustomDomain returns the configured custom domain for a frontend.

func (*Client) GetFrontendDeploymentLogs

func (c *Client) GetFrontendDeploymentLogs(ctx context.Context, projectID, frontendID, deploymentID uuid.UUID, limit int, nextToken string) (*apiclient.GetLogsResponse, error)

GetFrontendDeploymentLogs returns one build log page for a frontend deployment.

func (*Client) GetFrontendLogs

func (c *Client) GetFrontendLogs(ctx context.Context, projectID, frontendID uuid.UUID, limit int, nextToken string) (*apiclient.GetLogsResponse, error)

GetFrontendLogs returns one runtime log page for a frontend.

func (*Client) GetFunction

func (c *Client) GetFunction(ctx context.Context, projectID, functionID uuid.UUID) (*apiclient.Function, error)

GetFunction returns one function by ID.

func (*Client) GetFunctionDeploymentLogs

func (c *Client) GetFunctionDeploymentLogs(ctx context.Context, projectID, functionID, deploymentID uuid.UUID, limit int, nextToken string) (*apiclient.GetLogsResponse, error)

GetFunctionDeploymentLogs returns one build log page for a function deployment.

func (*Client) GetFunctionLogs

func (c *Client) GetFunctionLogs(ctx context.Context, projectID, functionID uuid.UUID, limit int, nextToken string) (*apiclient.GetLogsResponse, error)

GetFunctionLogs returns one runtime log page for a function.

func (*Client) GetProject

func (c *Client) GetProject(ctx context.Context, projectID uuid.UUID) (*apiclient.Project, error)

GetProject returns one project by ID.

func (*Client) GetStorageBucket

func (c *Client) GetStorageBucket(ctx context.Context, projectID uuid.UUID, bucketName string) (*apiclient.StorageBucket, error)

GetStorageBucket returns one bucket by name.

func (*Client) GetStorageStats

func (c *Client) GetStorageStats(ctx context.Context, projectID uuid.UUID) (*apiclient.StorageStats, error)

GetStorageStats returns aggregate storage statistics for a project.

func (*Client) GetVariable

func (c *Client) GetVariable(ctx context.Context, projectID uuid.UUID, name string) (*apiclient.Variable, error)

GetVariable returns one variable by name.

func (*Client) ListDatabases

func (c *Client) ListDatabases(ctx context.Context, projectID uuid.UUID, page, limit int) (*apiclient.PaginatedDatabases, error)

ListDatabases lists one database page for a project.

func (*Client) ListFrontendDeployments

func (c *Client) ListFrontendDeployments(ctx context.Context, projectID, frontendID uuid.UUID, page, limit int) (*apiclient.PaginatedFrontendDeployments, error)

ListFrontendDeployments lists one deployment page for a frontend.

func (*Client) ListFrontends

func (c *Client) ListFrontends(ctx context.Context, projectID uuid.UUID, page, limit int) (*apiclient.PaginatedFrontends, error)

ListFrontends lists one frontend page for a project.

func (*Client) ListFunctionDeployments

func (c *Client) ListFunctionDeployments(ctx context.Context, projectID, functionID uuid.UUID, page, limit int) (*apiclient.PaginatedFunctionDeployments, error)

ListFunctionDeployments lists one deployment page for a function.

func (*Client) ListFunctionRuntimes

func (c *Client) ListFunctionRuntimes(ctx context.Context) ([]apiclient.FunctionRuntimeOption, error)

ListFunctionRuntimes returns the function runtime catalog.

func (*Client) ListFunctionSchedulers

func (c *Client) ListFunctionSchedulers(ctx context.Context, projectID, functionID uuid.UUID) (*apiclient.FunctionSchedulerListResponse, error)

ListFunctionSchedulers lists schedulers for a function.

func (*Client) ListFunctions

func (c *Client) ListFunctions(ctx context.Context, projectID uuid.UUID, page, limit int) (*apiclient.PaginatedFunctions, error)

ListFunctions lists one function page for a project.

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context, page, limit int) (*apiclient.PaginatedProjects, error)

ListProjects lists one project page for the authenticated user.

func (*Client) ListStorageBuckets

func (c *Client) ListStorageBuckets(ctx context.Context, projectID uuid.UUID) ([]apiclient.StorageBucket, error)

ListStorageBuckets returns every bucket in the project.

func (*Client) ListStorageObjects

func (c *Client) ListStorageObjects(ctx context.Context, bucketName string, opts StorageObjectListOptions) (*apiclient.StorageListResponse, error)

ListStorageObjects returns one cursor page of objects in a bucket.

func (*Client) ListStoragePolicies

func (c *Client) ListStoragePolicies(ctx context.Context, projectID uuid.UUID, bucketName string) ([]apiclient.StoragePolicy, error)

ListStoragePolicies returns every policy attached to a bucket.

func (*Client) ListVariables

func (c *Client) ListVariables(ctx context.Context, projectID uuid.UUID, page, limit int) (*apiclient.PaginatedVariables, error)

ListVariables lists one variable page for a project.

func (*Client) MoveStorageObject

func (c *Client) MoveStorageObject(ctx context.Context, bucketName, from, to string) (*apiclient.StorageObject, error)

MoveStorageObject renames one object within a bucket.

func (*Client) PollDeviceToken

func (c *Client) PollDeviceToken(ctx context.Context, clientID, deviceCode string) (*DeviceTokenPollResult, error)

PollDeviceToken polls the OAuth device token endpoint once.

func (*Client) RedeployFrontend

func (c *Client) RedeployFrontend(ctx context.Context, projectID, frontendID uuid.UUID) (*apiclient.Frontend, error)

RedeployFrontend starts a new deployment using the last uploaded archive.

func (*Client) SetStorageObjectVisibility

func (c *Client) SetStorageObjectVisibility(ctx context.Context, bucketName, path string, isPublic bool) (*apiclient.StorageObject, error)

SetStorageObjectVisibility updates the public/private flag for one object.

func (*Client) StartDeviceAuthorization

func (c *Client) StartDeviceAuthorization(ctx context.Context, clientID string) (*apiclient.DeviceAuthorizationResponse, error)

StartDeviceAuthorization starts the OAuth device authorization flow.

func (*Client) UpdateFunctionScheduler

func (c *Client) UpdateFunctionScheduler(ctx context.Context, projectID, functionID, schedulerID uuid.UUID, input FunctionSchedulerInput) (*apiclient.FunctionScheduler, error)

UpdateFunctionScheduler updates one scheduler for a function.

func (*Client) UpdateFunctionVisibility

func (c *Client) UpdateFunctionVisibility(ctx context.Context, projectID, functionID uuid.UUID, isPublic bool) (*apiclient.Function, error)

UpdateFunctionVisibility updates one function's public/private visibility.

func (*Client) UpdateStorageBucket

func (c *Client) UpdateStorageBucket(ctx context.Context, projectID uuid.UUID, bucketName string, input StorageBucketUpdateInput) (*apiclient.StorageBucket, error)

UpdateStorageBucket updates one bucket's configuration.

func (*Client) UpdateVariable

func (c *Client) UpdateVariable(ctx context.Context, projectID uuid.UUID, name, value string) (*apiclient.Variable, error)

UpdateVariable updates one variable by name.

func (*Client) UploadStorageObject

func (c *Client) UploadStorageObject(ctx context.Context, bucketName, path, contentType string, content io.Reader) (*apiclient.StorageObject, error)

UploadStorageObject uploads one object to a bucket via a streaming multipart request. The body is assembled lazily through an io.Pipe so the caller's reader is consumed in fixed-size chunks rather than buffered in memory.

func (*Client) ValidateToken

func (c *Client) ValidateToken(ctx context.Context) error

ValidateToken validates the configured token by listing projects.

type DeviceTokenPollResult

type DeviceTokenPollResult struct {
	AccessToken      string
	Error            string
	ErrorDescription string
}

DeviceTokenPollResult is the normalized result of a device-token poll.

type Error

type Error struct {
	StatusCode int
	Message    string
}

Error is a normalized error returned for non-successful API responses.

func (*Error) Error

func (e *Error) Error() string

type FrontendCustomDomainInput

type FrontendCustomDomainInput struct {
	Domain              string
	CertificatePEM      string
	PrivateKeyPEM       string
	CertificateChainPEM string
}

FrontendCustomDomainInput contains one custom domain attach request.

type FrontendDeployInput

type FrontendDeployInput struct {
	Name      string
	Framework string
	AppRoot   string
	Archive   []byte
}

FrontendDeployInput contains one packaged frontend source archive.

type FunctionDeployInput

type FunctionDeployInput struct {
	Name          string
	Runtime       string
	Handler       string
	SourceArchive []byte
}

FunctionDeployInput contains one packaged function source archive.

type FunctionSchedulerInput

type FunctionSchedulerInput struct {
	Name           string
	CronExpression string
	Payload        map[string]any
	Regions        []string
	Enabled        *bool
}

FunctionSchedulerInput contains one function scheduler create or update request.

type Option

type Option func(*options)

Option configures a cloud API client.

func WithHTTPClient

func WithHTTPClient(httpClient apiclient.HttpRequestDoer) Option

WithHTTPClient injects the HTTP client used by the generated API client.

type StorageBucketCreateInput

type StorageBucketCreateInput struct {
	Name             string
	AllowedMimeTypes []string
	FileSizeLimit    *int64
}

StorageBucketCreateInput captures fields supported by bucket creation.

type StorageBucketUpdateInput

type StorageBucketUpdateInput struct {
	AllowedMimeTypes *[]string
	FileSizeLimit    *int64
}

StorageBucketUpdateInput captures fields supported by bucket update.

type StorageObjectListOptions

type StorageObjectListOptions struct {
	Prefix string
	Limit  int
	Cursor string
}

StorageObjectListOptions controls the object list query.

type StoragePolicyCreateInput

type StoragePolicyCreateInput struct {
	Name       string
	Definition string
	Operation  apicommon.CreateStoragePolicyRequestOperation
}

StoragePolicyCreateInput captures fields supported by policy creation.

Jump to

Keyboard shortcuts

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