console

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 26 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

Overview

Package console provides an HTTP client for the Akash Console API at https://console-api.akash.network (managed wallets, deployments, and the public marketplace/catalog endpoints).

Authenticated endpoints require an API key sent via the x-api-key header. Public endpoints work without a key; the key is still sent when configured.

Wire conventions: most write bodies are wrapped in a {"data": ...} envelope and most responses arrive as {"data": ...}. Exceptions (top-level arrays or objects) are noted on the individual methods.

Index

Constants

View Source
const (
	MaxProjectNameLength        = 64
	MaxProjectDescriptionLength = 140
)

Limits the Console API applies to project fields (POST/PATCH /v1/projects).

View Source
const (
	HeaderOrganizationID = "x-organization-id"
	HeaderProjectID      = "x-project-id"
)

Request scope headers of the Console API (SPEC §7.1.1). The organization header takes an organization id or slug; the project header takes a project id.

View Source
const (
	CodeOrganizationForbidden = "organization_forbidden"
	CodeOrganizationMismatch  = "organization_mismatch"
	CodeProjectForbidden      = "project_forbidden"
	CodeProjectRequired       = "project_required"
	CodeProjectBudgetExceeded = "project_budget_exceeded"
	CodeSessionRequired       = "session_required"
	CodeProjectNameTaken      = "project_name_taken"
	CodeProjectIsDefault      = "project_is_default"
	CodeProjectNotEmpty       = "project_not_empty"
	CodeProjectLimitReached   = "project_limit_reached"
	// CodeDepositPriceUnavailable comes with a 503: Console could not price
	// a deposit against the project's budget and refused before signing.
	CodeDepositPriceUnavailable = "deposit_price_unavailable"
)

Console API error codes for teams and projects (SPEC §7.6). The API sends them in the error body's `code` field.

View Source
const DefaultBaseURL = "https://console-api.akash.network"

DefaultBaseURL is the production Console API endpoint.

View Source
const DefaultUIBaseURL = "https://console.akash.network"

DefaultUIBaseURL is the production Console browser origin.

View Source
const ErrTeamsUnavailable sentinelError = "console: teams and projects are not enabled for this Console account"

ErrTeamsUnavailable reports that the Console API answers its organization and project routes as unknown for this account: teams are not enabled for it yet, so the key acts in its personal account as before.

View Source
const MaxJWTTTLSeconds = 3600

MaxJWTTTLSeconds bounds Console-issued provider credentials.

Variables

View Source
var (
	// ErrUnauthorized indicates the API key is missing, invalid, or expired
	// (HTTP 401).
	ErrUnauthorized = errors.New("console: invalid or expired API key")

	// ErrInsufficientFunds indicates the managed wallet cannot cover the
	// operation (HTTP 402).
	ErrInsufficientFunds = errors.New("console: insufficient funds")

	// ErrNotFound indicates the requested resource does not exist (HTTP 404).
	ErrNotFound = errors.New("console: resource not found")

	// ErrAlreadyClosed is returned by CloseDeployment when the deployment is
	// already closed or absent (the preflight answers 404 or reports a closed
	// state, or the DELETE reports unambiguous already-closed semantics).
	// Callers must preserve this as a failed mutation.
	ErrAlreadyClosed = errors.New("console: deployment already closed")
)

Sentinel errors returned by the client. Match with errors.Is.

Functions

func LoadManifest

func LoadManifest(root, ctxName, dseq string) (string, error)

LoadManifest reads a previously cached manifest. The dseq is validated as a plain numeric sequence so user-supplied values cannot read arbitrary files. The returned error wraps fs.ErrNotExist when no manifest has been cached for the dseq.

func ManifestPath

func ManifestPath(root, ctxName, dseq string) (string, error)

ManifestPath returns the cache path for a deployment's manifest: <root>/contexts/<ctxName>/manifests/<dseq>.json. The dseq must be a plain numeric sequence; anything else (e.g. a path-traversal attempt) is an error.

func SaveManifest

func SaveManifest(root, ctxName, dseq, manifest string) error

SaveManifest caches a deployment manifest under the context's manifests directory with mode 0600 (manifests can reference private registries or env values). The dseq is validated as a plain numeric sequence first: it comes from the Console API response, and a hostile value must not steer the write outside the config root.

Types

type APIKey

type APIKey struct {
	ID             string  `json:"id"`
	Name           string  `json:"name"`
	ExpiresAt      string  `json:"expiresAt,omitempty"`
	CreatedAt      string  `json:"createdAt,omitempty"`
	LastUsedAt     string  `json:"lastUsedAt,omitempty"`
	KeyFormat      string  `json:"keyFormat,omitempty"`
	OrganizationID *string `json:"organizationId,omitempty"`
	ProjectID      *string `json:"projectId,omitempty"`
}

APIKey describes an existing API key (GET /v1/api-keys). The secret is never returned after creation. OrganizationID is the organization the key acts in and ProjectID the one project it is limited to. Console reports null for a key that predates organizations or reaches every project, and both are then omitted.

type Attribute

type Attribute struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Attribute is a provider attribute requirement key/value pair.

type Auditor

type Auditor struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Address string `json:"address"`
	Website string `json:"website,omitempty"`
}

Auditor is one entry of GET /v1/auditors.

type Balances

type Balances struct {
	Balance     int64 `json:"balance"`
	Deployments int64 `json:"deployments"`
	Total       int64 `json:"total"`
}

Balances reports managed-wallet balances in µACT integer units (GET /v1/balances). ACT is pegged 1:1 to USD, so USD = value / 1e6.

func (Balances) BalanceUSD

func (b Balances) BalanceUSD() float64

BalanceUSD returns the free balance in USD.

func (Balances) DeploymentsUSD

func (b Balances) DeploymentsUSD() float64

DeploymentsUSD returns the funds locked in deployment escrow in USD.

func (Balances) TotalUSD

func (b Balances) TotalUSD() float64

TotalUSD returns the total balance in USD.

type Bid

type Bid struct {
	ID    LeaseID `json:"id"`
	State string  `json:"state"`
	Price *Price  `json:"price,omitempty"`
}

Bid is a provider bid on an open order (GET /v1/bids?dseq=).

type BidScreeningRequest

type BidScreeningRequest struct {
	Requirements      BidScreeningRequirements `json:"requirements"`
	Resources         json.RawMessage          `json:"resources,omitempty"`
	Timezone          string                   `json:"timezone,omitempty"`
	ReclamationWindow json.RawMessage          `json:"reclamationWindow,omitempty"`
}

BidScreeningRequest is the body of POST /v1/bid-screening (not data-enveloped). Resources and ReclamationWindow are passed through raw so callers can supply whatever shape the SDL produced.

The API requires Resources and Timezone; ScreenBids rejects requests missing either before hitting the network. Timezone must be an IANA zone name (e.g. "America/Chicago").

type BidScreeningRequirements

type BidScreeningRequirements struct {
	SignedBy   SignedBy    `json:"signedBy"`
	Attributes []Attribute `json:"attributes,omitempty"`
}

BidScreeningRequirements narrows the provider set for bid screening. An empty Attributes list is omitted on the wire (the API schema types it as a non-nullable array, so JSON null is rejected).

type Client

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

Client interacts with the Akash Console API.

func New

func New(baseURL, apiKey string) *Client

New creates a Console API client. An empty baseURL selects DefaultBaseURL. The apiKey may be empty when only public endpoints are used.

func (*Client) ActiveOrganization added in v1.1.0

func (c *Client) ActiveOrganization(ctx context.Context) (*Organization, error)

ActiveOrganization returns the organization this client's requests run in.

func (*Client) CloseDeployment

func (c *Client) CloseDeployment(ctx context.Context, dseq string) error

CloseDeployment closes an active deployment. It first reads the deployment so an absent or already-closed target is reported as ErrAlreadyClosed and no DELETE is sent. The command therefore never reports a mutation it did not perform.

Wire: DELETE /v1/deployments/{dseq}.

func (*Client) CreateAPIKey

func (c *Client) CreateAPIKey(ctx context.Context, name, expiresAt string) (*CreatedAPIKey, error)

CreateAPIKey creates a new API key. expiresAt is optional (RFC 3339; empty means no expiry). The returned CreatedAPIKey.APIKey secret is shown exactly once — persist it immediately.

Wire: POST /v1/api-keys, body {"data":{"name":..., "expiresAt"?:...}}, data-enveloped response.

func (*Client) CreateAPIKeyForProject added in v1.1.0

func (c *Client) CreateAPIKeyForProject(ctx context.Context, name, expiresAt, projectID string) (*CreatedAPIKey, error)

CreateAPIKeyForProject creates an API key limited to one project of the active organization; an empty projectID creates one that reaches every project its owner can. The key acts in the organization it is created in.

Wire: POST /v1/api-keys, body {"data":{"name":..., "expiresAt"?:..., "projectId"?:...}}.

func (*Client) CreateDeployment

func (c *Client) CreateDeployment(ctx context.Context, sdl string, options ...CreateDeploymentOptions) (*CreateDeploymentResult, error)

CreateDeployment creates a deployment via the managed wallet. There is no deposit: the platform funds the deployment from the account's credits. An explicit options value seals new secrets, including an empty map for ordinary variables. Lease creation then uses the server's saved definition. Calls without options retain the legacy reconciliation contract.

Wire: POST /v1/deployments, body {"data":{"sdl":...}}.

func (*Client) CreateDeploymentJWTToken added in v1.1.0

func (c *Client) CreateDeploymentJWTToken(ctx context.Context, ttl int, provider, dseq string, scope []string) (string, error)

CreateDeploymentJWTToken mints a short-lived JWT for one deployment's leases on one provider, for direct provider access. Inside a team, an API key limited to some projects (a project-bound key, a selected project, or a member's or viewer's key) may only mint tokens that name their deployments this way. Without a selected project the client first asks for the broader scoped token, which every key without teams uses, and falls back to the deployment grant only when Console refuses it with project_forbidden.

Wire: POST /v1/create-jwt-token, body {"data":{"ttl":..., "leases": {"access":"granular","permissions":[{"provider":...,"access":"granular", "deployments":[{"dseq":N,"scope":[...],"services":["*"]}]}]}}}.

func (*Client) CreateJWTToken

func (c *Client) CreateJWTToken(ctx context.Context, ttl int, scope []string) (string, error)

CreateJWTToken mints a short-lived JWT scoped to the given lease permissions, for direct provider access. ttl is in seconds.

Wire: POST /v1/create-jwt-token, body {"data":{"ttl":..., "leases":{"access":"scoped","scope":[...]}}}, response {"data":{"token":...}}.

func (*Client) CreateLease

func (c *Client) CreateLease(ctx context.Context, manifest string, leases []LeaseRequest) (*DeploymentDetail, error)

CreateLease accepts one or more bids and sends the deployment manifest to the winning providers.

Wire: POST /v1/leases. NOTE: unlike other writes, the request body is NOT data-enveloped: {"manifest":..., "leases":[{dseq,gseq,oseq,provider}]}. The response is data-enveloped.

func (*Client) CreateProject added in v1.1.0

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

CreateProject creates a project in the active organization. An empty description is omitted.

Wire: POST /v1/projects, body {"data":{"name":..., "description"?:...}}, data-enveloped response.

func (*Client) DeleteAPIKey

func (c *Client) DeleteAPIKey(ctx context.Context, id string) error

DeleteAPIKey deletes an API key by ID. Console's DELETE endpoint is idempotent, so the client first proves the key is present in the account's key list. A missing key is returned as ErrNotFound without sending DELETE, ensuring callers never report a deletion the API did not perform.

Wire: DELETE /v1/api-keys/{id} → 204.

func (*Client) DeleteProject added in v1.1.0

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

DeleteProject deletes a project that holds no open deployment. Console refuses the organization's default project.

Wire: DELETE /v1/projects/{id} → 204.

func (*Client) DeploymentURL added in v0.1.0

func (c *Client) DeploymentURL(dseq string) string

DeploymentURL returns a production Console deep link for dseq. Custom API origins intentionally return an empty string: they may have no matching UI, and linking them to production would point at a different account.

func (*Client) FetchBids

func (c *Client) FetchBids(ctx context.Context, dseq string) ([]Bid, error)

FetchBids fetches bids for a deployment's open orders.

Wire: GET /v1/bids?dseq=, response {"data":[{"bid":{...}}]}.

func (*Client) FindProject added in v1.1.0

func (c *Client) FindProject(ctx context.Context, selector string) (*ListedProject, error)

FindProject resolves a project id, slug, or name among the projects the caller can reach.

func (*Client) ForProject added in v1.1.0

func (c *Client) ForProject(project string) *Client

ForProject returns a copy of the client acting in another project of the same organization; an empty project acts across every project the API key reaches. The receiver is unchanged, so a long-lived client (the MCP server's) can serve one call in a different project.

func (*Client) GetBalances

func (c *Client) GetBalances(ctx context.Context) (*Balances, error)

GetBalances fetches managed-wallet balances in µACT integer units. Use the *USD helpers on Balances for display values.

Wire: GET /v1/balances, data-enveloped response.

func (*Client) GetDeployment

func (c *Client) GetDeployment(ctx context.Context, dseq string) (*DeploymentDetail, error)

GetDeployment fetches a single deployment with its leases and escrow account.

Wire: GET /v1/deployments/{dseq}, data-enveloped response.

func (*Client) GetDeploymentDefinition added in v1.0.1

func (c *Client) GetDeploymentDefinition(ctx context.Context, dseq string) (*DeploymentDefinition, error)

GetDeploymentDefinition returns Console's saved SDL and concurrency token.

func (*Client) GetDeploymentSettings

func (c *Client) GetDeploymentSettings(ctx context.Context, dseq string) (*DeploymentSettings, error)

GetDeploymentSettings fetches auto-top-up settings for a deployment. Returns an error matching ErrNotFound when no settings exist yet.

Wire: GET /v2/deployment-settings/{dseq}, data-enveloped response.

func (*Client) GetGPUPrices

func (c *Client) GetGPUPrices(ctx context.Context) (*GPUPrices, error)

GetGPUPrices fetches the network-wide GPU availability and price catalog.

Wire: GET /v1/gpu-prices, top-level object (not data-enveloped).

func (*Client) GetProvider

func (c *Client) GetProvider(ctx context.Context, address string) (*ProviderDetail, error)

GetProvider fetches detailed information (including stats and hostUri) for one provider. Common fields are typed; the full document is preserved in ProviderDetail.Raw.

Wire: GET /v1/providers/{address}, top-level object.

func (*Client) GetSecretsContext added in v1.0.1

func (c *Client) GetSecretsContext(ctx context.Context) (*SecretsContext, error)

GetSecretsContext reads and validates the user's current public sealing key.

func (*Client) GetTemplate

func (c *Client) GetTemplate(ctx context.Context, id string) (*Template, error)

GetTemplate fetches one deployment template by ID.

Wire: GET /v1/templates/{id}, data-enveloped response.

func (*Client) GetUsageHistory

func (c *Client) GetUsageHistory(ctx context.Context, address, startDate, endDate string) ([]UsagePoint, error)

GetUsageHistory fetches daily spend history for an address between startDate and endDate (YYYY-MM-DD). Empty dates are omitted — the API then defaults endDate to today and startDate to 30 days before endDate; sending an empty string fails the API's format=date validation.

Wire: GET /v1/usage/history?address=&startDate=&endDate=. NOTE: the response is a TOP-LEVEL array, not data-enveloped.

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context) (*User, error)

GetUser fetches the authenticated Console user. The returned User.ID is the internal UUID needed by ListWallets.

Wire: GET /v1/user/me, data-enveloped response.

func (*Client) GetWalletSettings

func (c *Client) GetWalletSettings(ctx context.Context) (*WalletSettings, error)

GetWalletSettings fetches account-level wallet settings.

Wire: GET /v1/wallet-settings, data-enveloped response.

func (*Client) GetWeeklyCost

func (c *Client) GetWeeklyCost(ctx context.Context) (float64, error)

GetWeeklyCost fetches the trailing weekly spend in USD.

Wire: GET /v1/weekly-cost, response {"data":{"weeklyCost":...}}.

func (*Client) ListAPIKeys

func (c *Client) ListAPIKeys(ctx context.Context) ([]APIKey, error)

ListAPIKeys lists the account's API keys. Secrets are never included.

Wire: GET /v1/api-keys, response {"data":[...]}.

func (*Client) ListAuditors

func (c *Client) ListAuditors(ctx context.Context) ([]Auditor, error)

ListAuditors lists known auditors.

Wire: GET /v1/auditors, TOP-LEVEL array.

func (*Client) ListDeployments

func (c *Client) ListDeployments(ctx context.Context, skip, limit int) (*DeploymentList, error)

ListDeployments lists deployments with validated pagination. With a selected project, only the deployments filed in it are listed.

Wire: GET /v1/deployments?skip=&limit=[&projectId=], data-enveloped response.

func (*Client) ListDeploymentsByState added in v0.1.0

func (c *Client) ListDeploymentsByState(ctx context.Context, state string, skip, limit int) (*DeploymentList, error)

ListDeploymentsByState traverses the bounded deployment collection, applies the state filter, and only then applies the requested page window.

func (*Client) ListOrganizations added in v1.1.0

func (c *Client) ListOrganizations(ctx context.Context) ([]Organization, error)

ListOrganizations lists the organizations the caller acts in. An API key acts in exactly one, which is returned with IsActive set.

Wire: GET /v1/organizations, response {"data":[...]}.

func (*Client) ListProjects added in v1.1.0

func (c *Client) ListProjects(ctx context.Context) ([]ListedProject, error)

ListProjects lists the projects of the active organization the caller can reach, most recently active first.

Wire: GET /v1/projects, response {"data":[...]}.

func (*Client) ListProviderRegions

func (c *Client) ListProviderRegions(ctx context.Context) ([]ProviderRegion, error)

ListProviderRegions lists the regions providers advertise.

Wire: GET /v1/provider-regions, TOP-LEVEL array.

func (*Client) ListProviders

func (c *Client) ListProviders(ctx context.Context, scope string, addresses []string) ([]Provider, error)

ListProviders lists providers. scope is optional (e.g. "trial"); addresses optionally restricts the result to specific provider addresses.

Wire: GET /v1/providers?scope=&addresses=. NOTE: the response is a TOP-LEVEL array, not data-enveloped.

func (*Client) ListTemplates

func (c *Client) ListTemplates(ctx context.Context) (json.RawMessage, error)

ListTemplates fetches the template catalog. The category/template tree is loosely specified upstream, so the enveloped payload is returned raw.

Wire: GET /v1/templates-list, data-enveloped response.

func (*Client) ListWallets

func (c *Client) ListWallets(ctx context.Context, userID string) ([]Wallet, error)

ListWallets lists managed wallets for a user. userID is the internal UUID from GetUser().ID, not the userId field.

Wire: GET /v1/wallets?userId=, response {"data":[...]}.

func (*Client) ManagedWalletAddress added in v0.1.2

func (c *Client) ManagedWalletAddress(ctx context.Context) (string, error)

ManagedWalletAddress resolves the authenticated user's first managed wallet with a nonblank on-chain address.

func (*Client) MoveDeployment added in v1.1.0

func (c *Client) MoveDeployment(ctx context.Context, dseq, projectID string) (*DeploymentProject, error)

MoveDeployment files a deployment in another project of the active organization. The request deliberately carries no project header: a request narrowed to the deployment's current project could not reach the target.

Wire: PATCH /v1/deployments/{dseq}/project, body {"data":{"projectId":...}}, response {"data":{"dseq":...,"projectId":...}}.

func (*Client) Organization added in v1.1.0

func (c *Client) Organization() string

Organization returns the organization selector this client sends, or "".

func (*Client) PatchDeployment added in v1.0.1

func (c *Client) PatchDeployment(ctx context.Context, dseq string, patch deploymentconfig.Patch, secrets SecretValues) (*DeploymentDetail, error)

PatchDeployment changes only the named fields and seals only supplied secret replacements. Omitted secret names retain their values on the server.

func (*Client) Project added in v1.1.0

func (c *Client) Project() string

Project returns the project selector this client was given, or "".

func (*Client) ProjectID added in v1.1.0

func (c *Client) ProjectID(ctx context.Context) (string, error)

ProjectID resolves the selected project to its id, or returns "" when no project is selected.

func (*Client) RenameProject added in v1.1.0

func (c *Client) RenameProject(ctx context.Context, projectID, name string) (*Project, error)

RenameProject gives a project a new name; its slug and id are unchanged.

Wire: PATCH /v1/projects/{id}, body {"data":{"name":...}}, data-enveloped response.

func (*Client) ScreenBids

func (c *Client) ScreenBids(ctx context.Context, req *BidScreeningRequest) ([]ScreenedProvider, error)

ScreenBids asks the Console API which providers can satisfy the given requirements/resources before a deployment is created. The API contract requires both Resources and Timezone (an IANA zone name); requests missing either are rejected locally instead of triggering an HTTP 400.

Wire: POST /v1/bid-screening (request and response are NOT data-enveloped; the response is {"providers":[...]}).

func (*Client) SetDeploymentRuntimeLimit added in v1.0.1

func (c *Client) SetDeploymentRuntimeLimit(ctx context.Context, dseq string, hours *int) (*DeploymentSettings, error)

SetDeploymentRuntimeLimit sets a deployment's runtime limit in hours, or clears it (hours == nil) to return the deployment to always-on funding.

There is no auto-top-up counterpart: always-on funding cannot be switched off, and the API rejects an explicit autoTopUpEnabled:false, so the runtime limit is the only per-deployment funding control a client can set.

Wire: PATCH /v2/deployment-settings/{dseq}, body {"data":{"runtimeLimitHours": <hours>|null}}. There is no POST fallback: the create endpoint's body has no runtime-limit field, and GET is get-or-create, so a settings record always exists by the time we PATCH.

func (*Client) UpdateDeployment

func (c *Client) UpdateDeployment(ctx context.Context, dseq, sdl string, options ...UpdateDeploymentOptions) (*DeploymentDetail, error)

UpdateDeployment updates a deployment's SDL.

With options, saved definitions use PATCH to preserve existing secrets. Ordinary legacy deployments without saved definitions retain the full-SDL PUT contract. Calls without options preserve that legacy client behavior.

func (*Client) UpdateWalletSettings

func (c *Client) UpdateWalletSettings(ctx context.Context, autoReloadEnabled bool) (*WalletSettings, error)

UpdateWalletSettings enables or disables wallet auto-reload and returns the stored settings.

Wire: PUT /v1/wallet-settings, body {"data":{"autoReloadEnabled":...}}; on 404, POST the same body to create the record. Data-enveloped response.

An account that has never configured auto-reload has no settings record at all, and PUT reports that as 404 — so the update would fail on exactly the accounts that have never set it, which is most of them. The API exposes POST for creation; falling back to it mirrors SetDeploymentAutoTopUp.

func (*Client) WithActionLog

func (c *Client) WithActionLog(l *actionlog.Logger) *Client

WithActionLog attaches a per-context action logger; state-changing Console API calls are then recorded as type=console entries (SPEC §5.6). A nil logger disables recording. Returns the client for chaining.

func (*Client) WithScope added in v1.1.0

func (c *Client) WithScope(organization, project string) *Client

WithScope selects the Console organization (id or slug) and project (id, slug, or name) every request of this client acts in. Empty values send no header, which leaves the API key's own scope in place: an account without teams sees no change. Returns the client for chaining.

type CreateDeploymentOptions added in v1.0.1

type CreateDeploymentOptions struct {
	Secrets            SecretValues
	InheritSecretsFrom string
}

CreateDeploymentOptions selects the saved-definition API and secret sealing.

type CreateDeploymentResult

type CreateDeploymentResult struct {
	DSeq     FlexString `json:"dseq"`
	Manifest string     `json:"manifest"`
	SignTx   *SignTx    `json:"signTx,omitempty"`
}

CreateDeploymentResult is the payload of POST /v1/deployments.

type CreatedAPIKey

type CreatedAPIKey struct {
	ID             string  `json:"id"`
	Name           string  `json:"name"`
	APIKey         string  `json:"apiKey"`
	OrganizationID *string `json:"organizationId,omitempty"`
	ProjectID      *string `json:"projectId,omitempty"`
}

CreatedAPIKey is the payload of POST /v1/api-keys. APIKey holds the secret, which is shown exactly once at creation time. OrganizationID and ProjectID report where the key acts, as on APIKey.

type Deployment

type Deployment struct {
	ID        DeploymentID    `json:"id"`
	State     string          `json:"state"`
	Hash      string          `json:"hash,omitempty"`
	CreatedAt json.RawMessage `json:"created_at,omitempty"`
}

Deployment is the chain-side deployment record embedded in Console responses.

type DeploymentDefinition added in v1.0.1

type DeploymentDefinition struct {
	SDL             string `json:"sdl"`
	ManifestVersion string `json:"manifestVersion"`
}

DeploymentDefinition is Console's saved, reference-bearing configuration. ManifestVersion is a concurrency token; it may precede an unsuccessful deployment update and therefore does not establish the current chain state.

type DeploymentDetail

type DeploymentDetail struct {
	Deployment      Deployment            `json:"deployment"`
	Leases          []Lease               `json:"leases"`
	EscrowAccount   json.RawMessage       `json:"escrow_account,omitempty"`
	ConsoleSettings *DeploymentDefinition `json:"consoleSettings,omitempty"`
	Name            *string               `json:"name,omitempty"`
	ManifestVersion string                `json:"manifestVersion,omitempty"`
}

DeploymentDetail is the payload of GET /v1/deployments/{dseq} (and of the update/lease-creation responses). EscrowAccount is kept raw; its state carries funds/transferred details.

type DeploymentID

type DeploymentID struct {
	Owner string     `json:"owner"`
	DSeq  FlexString `json:"dseq"`
}

DeploymentID identifies a deployment on chain.

type DeploymentList

type DeploymentList struct {
	Deployments []DeploymentListItem `json:"deployments"`
	Pagination  Pagination           `json:"pagination"`
}

DeploymentList is the payload of GET /v1/deployments.

type DeploymentListItem

type DeploymentListItem struct {
	Deployment Deployment `json:"deployment"`
	Leases     []Lease    `json:"leases"`
	ProjectID  *string    `json:"projectId,omitempty"`
}

DeploymentListItem is one entry of GET /v1/deployments. ProjectID is the project the deployment is filed in; Console reports it only to accounts with teams enabled, and it is omitted otherwise.

type DeploymentProject added in v1.1.0

type DeploymentProject struct {
	DSeq      FlexString `json:"dseq"`
	ProjectID string     `json:"projectId"`
}

DeploymentProject is the payload of PATCH /v1/deployments/{dseq}/project.

type DeploymentSettings

type DeploymentSettings struct {
	DSeq                 FlexString `json:"dseq"`
	AutoTopUpEnabled     bool       `json:"autoTopUpEnabled"`
	EstimatedTopUpAmount float64    `json:"estimatedTopUpAmount"`
	TopUpFrequencyMs     int64      `json:"topUpFrequencyMs"`
	RuntimeLimitHours    *int       `json:"runtimeLimitHours"`
	RuntimeEndsAt        *string    `json:"runtimeEndsAt"`
}

DeploymentSettings holds per-deployment automation settings (GET/PATCH /v2/deployment-settings/{dseq}).

func (DeploymentSettings) EstimatedTopUpUSD added in v0.0.3

func (s DeploymentSettings) EstimatedTopUpUSD() float64

EstimatedTopUpUSD returns the estimated top-up in USD.

The field is µACT like the rest of this rail, and was printed raw while every other money value goes through formatUSD -- so a $0.22 top-up read as "222945" on the setting that governs unattended spending.

type FlexString

type FlexString string

FlexString unmarshals from either a JSON string or a JSON number, since the Console API is inconsistent about numeric identifiers (dseq, amounts). It always marshals as a JSON string.

func (FlexString) String

func (s FlexString) String() string

String returns the underlying string value.

func (*FlexString) UnmarshalJSON

func (s *FlexString) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type GPUAvailability

type GPUAvailability struct {
	Total     int `json:"total"`
	Available int `json:"available"`
}

GPUAvailability summarizes network-wide GPU counts.

type GPUModel

type GPUModel struct {
	Vendor string        `json:"vendor"`
	Model  string        `json:"model"`
	RAM    string        `json:"ram"`
	Price  GPUPriceRange `json:"price"`
}

GPUModel is one entry of the GPU price catalog.

type GPUPriceRange

type GPUPriceRange struct {
	Min float64 `json:"min"`
	Max float64 `json:"max"`
	Avg float64 `json:"avg"`
}

GPUPriceRange is the observed price spread for a GPU model, USD per month.

type GPUPrices

type GPUPrices struct {
	Availability GPUAvailability `json:"availability"`
	Models       []GPUModel      `json:"models"`
}

GPUPrices is the payload of GET /v1/gpu-prices (not data-enveloped).

type HTTPError

type HTTPError struct {
	StatusCode int
	Body       string
	Code       string
}

HTTPError is returned for non-2xx statuses that have no dedicated mapping. Code carries a recognized team or project error code (SPEC §7.6), whose message then explains the refusal and its remedy instead of echoing Body.

func (*HTTPError) Error

func (e *HTTPError) Error() string

type Lease

type Lease struct {
	ID     LeaseID      `json:"id"`
	State  string       `json:"state"`
	Price  *Price       `json:"price,omitempty"`
	Status *LeaseStatus `json:"status,omitempty"`
}

Lease describes a lease attached to a deployment.

type LeaseID

type LeaseID struct {
	Owner    string     `json:"owner"`
	DSeq     FlexString `json:"dseq"`
	GSeq     uint32     `json:"gseq"`
	OSeq     uint32     `json:"oseq"`
	Provider string     `json:"provider"`
}

LeaseID identifies a lease (and doubles as a bid ID).

type LeaseRequest

type LeaseRequest struct {
	DSeq     string `json:"dseq"`
	GSeq     uint32 `json:"gseq"`
	OSeq     uint32 `json:"oseq"`
	Provider string `json:"provider"`
}

LeaseRequest identifies a specific bid to accept (POST /v1/leases).

type LeaseStatus

type LeaseStatus struct {
	Services       json.RawMessage `json:"services,omitempty"`
	ForwardedPorts json.RawMessage `json:"forwarded_ports,omitempty"`
	IPs            json.RawMessage `json:"ips,omitempty"`
}

LeaseStatus carries provider-reported runtime status. The deep structures are provider-defined, so they are kept raw.

type ListedProject added in v1.1.0

type ListedProject struct {
	Project
	LastActivityAt string              `json:"lastActivityAt"`
	Deployments    *ProjectDeployments `json:"deployments"`
	Access         ProjectAccess       `json:"access"`
}

ListedProject is one entry of GET /v1/projects: the project plus its recent activity, a preview of its active deployments, and what the caller may do in it.

func MatchProject added in v1.1.0

func MatchProject(projects []ListedProject, selector string) (*ListedProject, error)

MatchProject finds the one project a selector names: its id, its slug, or its name, compared without regard to case as Console compares names.

type Organization added in v1.1.0

type Organization struct {
	ID               string `json:"id"`
	Name             string `json:"name"`
	Slug             string `json:"slug"`
	Type             string `json:"type"`
	Role             string `json:"role"`
	IsActive         bool   `json:"isActive"`
	HasPaymentMethod *bool  `json:"hasPaymentMethod"`
	CreatedAt        string `json:"createdAt"`
}

Organization is one organization (a team, or the personal account) the caller acts in (GET /v1/organizations). IsActive marks the one the request ran in; Role is the caller's role there: owner, admin, member, billing, or viewer.

type Pagination

type Pagination struct {
	Total   int  `json:"total"`
	Skip    int  `json:"skip"`
	Limit   int  `json:"limit"`
	HasMore bool `json:"hasMore"`
}

Pagination describes list paging metadata.

type Price

type Price struct {
	Denom  string     `json:"denom"`
	Amount FlexString `json:"amount"`
}

Price is a denominated amount as reported by the chain.

type Project added in v1.1.0

type Project struct {
	ID          string          `json:"id"`
	Name        string          `json:"name"`
	Slug        string          `json:"slug"`
	Description *string         `json:"description"`
	IsDefault   bool            `json:"isDefault"`
	CreatedAt   string          `json:"createdAt"`
	CreatedBy   *ProjectCreator `json:"createdBy"`
}

Project is a project of the active organization (GET, POST, and PATCH /v1/projects). Every organization has one default project, which cannot be deleted.

type ProjectAccess added in v1.1.0

type ProjectAccess struct {
	CanDeploy bool `json:"canDeploy"`
	CanManage bool `json:"canManage"`
}

ProjectAccess reports whether the caller may deploy into a project and whether it may rename it and decide who else reaches it.

type ProjectCreator added in v1.1.0

type ProjectCreator struct {
	ID       string  `json:"id"`
	Username *string `json:"username"`
}

ProjectCreator names the user who created a project.

type ProjectDeploymentPreview added in v1.1.0

type ProjectDeploymentPreview struct {
	DSeq   FlexString `json:"dseq"`
	Name   *string    `json:"name"`
	Status string     `json:"status"`
}

ProjectDeploymentPreview is one of the newest active deployments of a project.

type ProjectDeployments added in v1.1.0

type ProjectDeployments struct {
	ActiveCount int                        `json:"activeCount"`
	Preview     []ProjectDeploymentPreview `json:"preview"`
}

ProjectDeployments summarizes a project's active deployments. Console reports null when the caller may not read them or too many are open to count.

type Provider

type Provider struct {
	Owner     string          `json:"owner"`
	Name      string          `json:"name,omitempty"`
	HostURI   string          `json:"hostUri,omitempty"`
	IsOnline  bool            `json:"isOnline,omitempty"`
	IsAudited bool            `json:"isAudited,omitempty"`
	Uptime1D  float64         `json:"uptime1d,omitempty"`
	Uptime7D  float64         `json:"uptime7d,omitempty"`
	Uptime30D float64         `json:"uptime30d,omitempty"`
	GPUModels json.RawMessage `json:"gpuModels,omitempty"`
	IPRegion  json.RawMessage `json:"ipRegion,omitempty"`
}

Provider is a provider summary (GET /v1/providers). GPUModels and IPRegion are kept raw: their shapes vary between deployments of the API.

type ProviderDetail

type ProviderDetail struct {
	Provider

	// Raw is the complete response body for callers that need fields not
	// modeled on Provider.
	Raw json.RawMessage `json:"-"`
}

ProviderDetail is the payload of GET /v1/providers/{address}: the typed summary fields plus the full raw document (stats etc.) in Raw.

type ProviderRegion

type ProviderRegion struct {
	Key         string   `json:"key"`
	Description string   `json:"description"`
	Providers   []string `json:"providers"`
}

ProviderRegion is one entry of GET /v1/provider-regions.

type ScreenedProvider

type ScreenedProvider struct {
	Owner        string          `json:"owner"`
	HostURI      string          `json:"hostUri,omitempty"`
	IsAudited    bool            `json:"isAudited,omitempty"`
	Location     json.RawMessage `json:"location,omitempty"`
	Organization string          `json:"organization,omitempty"`
}

ScreenedProvider is one provider returned by bid screening. Location is kept raw (object or string depending on API version).

type SecretValues added in v1.0.1

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

SecretValues holds plaintext only inside a request boundary. Its zero value means no secret source was supplied; an explicitly empty object is distinct.

func EmptySecretValues added in v1.0.1

func EmptySecretValues() SecretValues

EmptySecretValues represents an explicitly supplied empty secret map.

func ReadSecretValues added in v1.0.1

func ReadSecretValues(input io.Reader) (SecretValues, error)

ReadSecretValues accepts one bounded JSON or YAML object of string values. Parser errors deliberately omit source snippets, which may contain secrets.

func ReadSecretValuesFile added in v1.0.1

func ReadSecretValuesFile(path string, input io.Reader) (SecretValues, error)

ReadSecretValuesFile reads the optional secret source once. A dash selects the caller's input stream; files must be regular files, not pipes or devices.

func (SecretValues) Format added in v1.0.1

func (s SecretValues) Format(w fmt.State, _ rune)

Format prevents diagnostic formatting, including %#v, from exposing values.

func (SecretValues) Len added in v1.0.1

func (s SecretValues) Len() int

Len reports the number of supplied secrets without exposing their values.

func (SecretValues) Supplied added in v1.0.1

func (s SecretValues) Supplied() bool

Supplied reports whether a caller supplied a secret source, even an empty one.

type SecretsContext added in v1.0.1

type SecretsContext struct {
	Subject        string          `json:"sub"`
	KeyID          string          `json:"kid"`
	JWK            jose.JSONWebKey `json:"jwk"`
	RequiredClaims []string        `json:"requiredClaims"`
}

SecretsContext is the authenticated public encryption material supplied by Console.

type SessionRequiredError added in v1.1.0

type SessionRequiredError struct{}

SessionRequiredError reports an endpoint that needs a signed-in Console session, which an API key never is (HTTP 403, code session_required).

func (*SessionRequiredError) Error added in v1.1.0

func (err *SessionRequiredError) Error() string

func (*SessionRequiredError) Unwrap added in v1.1.0

func (*SessionRequiredError) Unwrap() error

type SignTx

type SignTx struct {
	Code            int    `json:"code"`
	TransactionHash string `json:"transactionHash"`
	RawLog          string `json:"rawLog"`
	// contains filtered or unexported fields
}

SignTx reports the broadcast result of a managed-wallet transaction.

func (*SignTx) UnmarshalJSON added in v0.1.0

func (s *SignTx) UnmarshalJSON(data []byte) error

UnmarshalJSON preserves whether code was present on the wire. A missing receipt code must not be confused with the zero success code.

type SignedBy

type SignedBy struct {
	AnyOf []string `json:"anyOf,omitempty"`
	AllOf []string `json:"allOf,omitempty"`
}

SignedBy expresses auditor requirements for bid screening. Empty lists are omitted on the wire: the API schema types anyOf/allOf as (non-nullable) string arrays, so serializing nil slices as JSON null violates the contract.

type Template

type Template struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Summary string `json:"summary,omitempty"`
	Deploy  string `json:"deploy,omitempty"`
	Readme  string `json:"readme,omitempty"`
}

Template is the payload of GET /v1/templates/{id}. Extra fields beyond the common ones are intentionally not modeled.

type UpdateDeploymentOptions added in v1.0.1

type UpdateDeploymentOptions struct {
	Secrets SecretValues
}

UpdateDeploymentOptions preserves stored secrets while applying SDL changes.

type UsagePoint

type UsagePoint struct {
	Date              string  `json:"date"`
	ActiveDeployments int     `json:"activeDeployments"`
	DailyUsdcSpent    float64 `json:"dailyUsdcSpent"`
	TotalUsdcSpent    float64 `json:"totalUsdcSpent"`
}

UsagePoint is one day of spend history (GET /v1/usage/history).

type User

type User struct {
	ID            string `json:"id"`
	UserID        string `json:"userId"`
	Username      string `json:"username"`
	Email         string `json:"email"`
	EmailVerified bool   `json:"emailVerified"`
}

User describes the authenticated Console user (GET /v1/user/me). ID is the internal UUID required by ListWallets.

type Wallet

type Wallet struct {
	Address      string  `json:"address"`
	CreditAmount float64 `json:"creditAmount"`
	IsTrialing   bool    `json:"isTrialing"`
	Denom        string  `json:"denom"`
}

Wallet describes a managed wallet (GET /v1/wallets?userId=).

func (Wallet) CreditUSD added in v0.0.3

func (w Wallet) CreditUSD() float64

CreditUSD returns the wallet credit in USD.

creditAmount is denominated in the units its own denom names, and that denom is "uact" -- micro-ACT, the same 1e6 scale as /v1/balances, with ACT pegged 1:1 to USD. Taking it for dollars printed an $11.35 wallet as $11,350,924.00 while `wallet balance` reported $57.49 for the same account. Any other denom is passed through unscaled rather than guessed at.

type WalletSettings

type WalletSettings struct {
	AutoReloadEnabled bool `json:"autoReloadEnabled"`
}

WalletSettings holds account-level wallet settings (GET/PUT /v1/wallet-settings).

Jump to

Keyboard shortcuts

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