api

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package api is a thin typed client for the public Privasys platform API (the management service). It speaks only the documented public surface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BillingResult added in v0.4.0

type BillingResult struct {
	Enabled bool                   `json:"enabled"`
	Data    map[string]interface{} `json:"data"`
}

BillingResult mirrors the management-service {enabled, data?} envelope used for credit-ledger reads. When billing is not configured, Enabled is false.

type Client

type Client struct {
	BaseURL string
	Token   string
	HTTP    *http.Client
}

Client calls the platform API with a bearer access token.

func New

func New(baseURL, token string) *Client

New creates a client for the given API base URL and access token.

func (*Client) ActiveDeploymentHost added in v0.10.0

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

ActiveDeploymentHost returns the gateway FQDN of the app's active deployment (the SNI the client connects to for direct RA-TLS). The hostname lives on the deployment record, not the app record.

func (*Client) AddAppOwner added in v0.3.0

func (c *Client) AddAppOwner(ctx context.Context, appID string, owner map[string]interface{}) (map[string]interface{}, error)

AddAppOwner grants a member access to an app ({sub, email?, name?}).

func (*Client) AddMember added in v0.3.0

func (c *Client) AddMember(ctx context.Context, member map[string]interface{}) (map[string]interface{}, error)

AddMember adds an account member ({sub, email?, name?, role?}).

func (*Client) AddRegistrySecret added in v0.16.0

func (c *Client) AddRegistrySecret(ctx context.Context, appID, name, cnf, enclaveID string) (*RegistrySecretResponse, error)

AddRegistrySecret asks the platform to author the pull-credential policy (the in-TD manager runtime gets ExportKey at pull time; the owner keeps control), mint a holder-of-key-bound grant, and record the handle on the app. cnf is the SHA-256 thumbprint of the owner's RA-TLS leaf; the grant is bound to it so only this client can create the material. enclaveID is optional (defaults to the app's assigned enclave).

func (*Client) BillingBalance added in v0.4.0

func (c *Client) BillingBalance(ctx context.Context) (*BillingResult, error)

BillingBalance returns the account's credit balance.

func (*Client) BillingLedger added in v0.4.0

func (c *Client) BillingLedger(ctx context.Context, limit int) (*BillingResult, error)

BillingLedger returns the credit-ledger history, optionally limited.

func (*Client) BillingPortal added in v0.4.0

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

BillingPortal returns a Stripe Customer Portal URL.

func (*Client) BillingSubscription added in v0.4.0

func (c *Client) BillingSubscription(ctx context.Context) (map[string]interface{}, error)

BillingSubscription returns the membership subscription state.

func (*Client) BillingUsage added in v0.4.0

func (c *Client) BillingUsage(ctx context.Context, since string) (*BillingResult, error)

BillingUsage returns the usage rollup, optionally since an RFC3339 time.

func (*Client) CheckName added in v0.2.0

func (c *Client) CheckName(ctx context.Context, name string) (map[string]interface{}, error)

CheckName reports whether an app name is available.

func (*Client) Checkout added in v0.4.0

func (c *Client) Checkout(ctx context.Context, kind string) (string, bool, error)

Checkout starts a Stripe Checkout session and returns its URL. kind is "membership" or "credits".

func (*Client) CompatibleEnclaves added in v0.2.0

func (c *Client) CompatibleEnclaves(ctx context.Context, id string) ([]map[string]interface{}, error)

CompatibleEnclaves lists enclaves an app can be deployed to.

func (*Client) CreateApp added in v0.2.0

func (c *Client) CreateApp(ctx context.Context, body map[string]interface{}) (map[string]interface{}, error)

CreateApp creates an app from the given request body (CreateAppRequest shape).

func (*Client) CreateVault added in v0.14.0

func (c *Client) CreateVault(ctx context.Context, name string) (map[string]interface{}, error)

CreateVault creates a user-facing vault (a key container) billed to the caller's account.

func (*Client) CreateVersion added in v0.2.0

func (c *Client) CreateVersion(ctx context.Context, id string, body map[string]string) (map[string]interface{}, error)

CreateVersion records a new version. The body is source-aware (the server branches on the app's source_type): {commit_url} for github, {image} for package, {channel} for cloud_image, plus an optional {version} semver.

func (*Client) DeleteApp added in v0.2.0

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

DeleteApp deletes an app by id.

func (*Client) DeleteRegistrySecret added in v0.16.0

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

DeleteRegistrySecret clears the app's pull credential so it pulls anonymously.

func (*Client) DeleteVault added in v0.14.0

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

DeleteVault removes a vault.

func (*Client) DeleteVaultKey added in v0.14.0

func (c *Client) DeleteVaultKey(ctx context.Context, vaultID, name string) error

DeleteVaultKey removes a key's catalogue entry from a vault.

func (*Client) DeployVersion added in v0.2.0

func (c *Client) DeployVersion(ctx context.Context, id, versionID, enclaveID string) (map[string]interface{}, error)

DeployVersion deploys a version to an enclave.

func (*Client) GetAccount added in v0.3.0

func (c *Client) GetAccount(ctx context.Context) (map[string]interface{}, error)

GetAccount returns the caller's account view ({account, role, members}).

func (*Client) GetApp

func (c *Client) GetApp(ctx context.Context, id string) (map[string]interface{}, error)

GetApp returns a single app's full record.

func (*Client) GetRegistrySecret added in v0.16.0

func (c *Client) GetRegistrySecret(ctx context.Context, appID string) (map[string]interface{}, error)

GetRegistrySecret reports whether the app has a pull credential configured (never the material).

func (*Client) GetVaultExportTarget added in v0.14.0

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

GetVaultExportTarget resolves the vault target for exporting an app's data key (GET /apps/{id}/vault-export-target). Owner-only on the server.

func (*Client) ListAppOwners added in v0.3.0

func (c *Client) ListAppOwners(ctx context.Context, appID string) (map[string]interface{}, error)

ListAppOwners returns an app's team ({owners, creator_sub}).

func (*Client) ListApps

func (c *Client) ListApps(ctx context.Context) ([]map[string]interface{}, error)

ListApps returns the caller's apps as generic records (the CLI renders a stable subset of columns and can emit the full objects as JSON/YAML, so it does not pin the full server schema).

func (*Client) ListBuilds added in v0.2.0

func (c *Client) ListBuilds(ctx context.Context, id string) ([]map[string]interface{}, error)

ListBuilds returns an app's build jobs.

func (*Client) ListDeployments added in v0.2.0

func (c *Client) ListDeployments(ctx context.Context, id string) ([]map[string]interface{}, error)

ListDeployments returns an app's deployments.

func (*Client) ListMembers added in v0.3.0

func (c *Client) ListMembers(ctx context.Context) (map[string]interface{}, error)

ListMembers returns the account's members ({members, owner_sub}).

func (*Client) ListPending added in v0.14.0

func (c *Client) ListPending(ctx context.Context, id, versionID string) (map[string]interface{}, error)

ListPending returns the pending vault key profiles for a version, with the staged measurement and per-vault K-of-N progress. Owner-only.

func (*Client) ListVaultKeys added in v0.14.0

func (c *Client) ListVaultKeys(ctx context.Context, vaultID string) ([]map[string]interface{}, error)

ListVaultKeys returns a vault's keys (catalogue).

func (*Client) ListVaults added in v0.14.0

func (c *Client) ListVaults(ctx context.Context) ([]map[string]interface{}, error)

ListVaults returns the caller's vaults.

func (*Client) ListVersions added in v0.2.0

func (c *Client) ListVersions(ctx context.Context, id string) ([]map[string]interface{}, error)

ListVersions returns an app's versions.

func (*Client) MCP added in v0.2.0

func (c *Client) MCP(ctx context.Context, id string) (map[string]interface{}, error)

MCP returns the app's MCP tool manifest.

func (*Client) MigrateConstellation added in v0.14.0

func (c *Client) MigrateConstellation(ctx context.Context, id, targetConstellationID string) (map[string]interface{}, error)

MigrateConstellation moves the app's vault-backed volume key onto a new constellation without re-encrypting data (graceful vault rotation). Empty targetConstellationID = the active constellation. Owner-only.

func (*Client) MintVaultKeyGrant added in v0.14.0

func (c *Client) MintVaultKeyGrant(ctx context.Context, vaultID, name, keyType, cnf string, exportable bool) (*VaultKeyGrantResponse, error)

MintVaultKeyGrant asks the platform to author the policy, catalogue the key and mint a holder-of-key-bound grant for a new key in the vault. cnf is the SHA-256 thumbprint of the agent's RA-TLS leaf; the grant is bound to it.

func (*Client) PromoteProfile added in v0.14.0

func (c *Client) PromoteProfile(ctx context.Context, id, versionID string, pendingID int, approvalTokens ...string) (map[string]interface{}, error)

PromoteProfile promotes (approves) a staged profile, authorizing the new measurement so the vault releases the data key to it. Owner-only.

approvalTokens carries any separation-of-duties co-sign JWTs the policy requires (item 3 / G.2): each must be a fresh approval token issued for the role-based Manager(0) by a SECOND team approver. Empty for apps that have not opted into co-sign (the default).

func (*Client) RemoveAppOwner added in v0.3.0

func (c *Client) RemoveAppOwner(ctx context.Context, appID, sub string) (map[string]interface{}, error)

RemoveAppOwner revokes a member's access to an app.

func (*Client) RemoveMember added in v0.3.0

func (c *Client) RemoveMember(ctx context.Context, sub string) (map[string]interface{}, error)

RemoveMember removes an account member.

func (*Client) RevokeProfile added in v0.14.0

func (c *Client) RevokeProfile(ctx context.Context, id, versionID string, pendingID int) (map[string]interface{}, error)

RevokeProfile drops a staged-but-unpromoted profile. Owner-only.

func (*Client) RotateKey added in v0.14.0

func (c *Client) RotateKey(ctx context.Context, id, versionID, enclaveID string) (map[string]interface{}, error)

RotateKey rotates the app's vault-backed volume KEK without re-encrypting data: it provisions a new key generation, re-keys the running container's LUKS keyslots online, advances the key handle, and retires the old generation. enclaveID is the enclave the app currently runs on. Owner-only.

func (*Client) RotateVaultKeyGrant added in v0.20.0

func (c *Client) RotateVaultKeyGrant(ctx context.Context, vaultID, name, cnf string) (*VaultKeyGrantResponse, error)

RotateVaultKeyGrant asks the platform to create a new primary version of an existing key (same type + policy), returning a grant bound to cnf for the new version's handle plus the constellation addressing.

func (*Client) Rpc added in v0.23.0

func (c *Client) Rpc(ctx context.Context, id, fn string, body interface{}) (map[string]interface{}, error)

Rpc invokes an app tool by name through the control-plane relay (POST /api/v1/apps/{id}/rpc/{fn}). Used for owner config/management operations (configure, actions, status polling); high-throughput data calls use direct RA-TLS via `app call`.

func (*Client) Schema added in v0.2.0

func (c *Client) Schema(ctx context.Context, id string) (map[string]interface{}, error)

Schema returns the app's exported function schema (unwraps {status, schema}).

func (*Client) SetMemberRole added in v0.3.0

func (c *Client) SetMemberRole(ctx context.Context, sub, role string) (map[string]interface{}, error)

SetMemberRole changes a member's account role.

func (*Client) SetVaultCosign added in v0.14.0

func (c *Client) SetVaultCosign(ctx context.Context, id string, require bool) (map[string]interface{}, error)

SetVaultCosign toggles separation-of-duties co-sign on promote for an app (item 3 / G.2). Owner-only.

func (*Client) StageProfile added in v0.14.0

func (c *Client) StageProfile(ctx context.Context, id, versionID, enclaveID string) (map[string]interface{}, error)

StageProfile stages a pending vault key profile for a version's measurement (MRTD + image digest on the target enclave). Owner-only.

func (*Client) StopDeployment added in v0.2.0

func (c *Client) StopDeployment(ctx context.Context, id, deploymentID string, force bool) (map[string]interface{}, error)

StopDeployment stops a running deployment.

func (*Client) UpdateAccount added in v0.3.0

func (c *Client) UpdateAccount(ctx context.Context, patch map[string]interface{}) (map[string]interface{}, error)

UpdateAccount patches the account (name, domain, kind).

func (*Client) UpdateStoreListing added in v0.14.0

func (c *Client) UpdateStoreListing(ctx context.Context, id string, fields map[string]interface{}) (map[string]interface{}, error)

UpdateStoreListing sets an app's App Store listing fields (PUT /apps/{id}/store). A Description and Category are required before the app can be deployed or published. Only the keys present in fields are sent.

func (*Client) UploadCwasm added in v0.2.0

func (c *Client) UploadCwasm(ctx context.Context, id, path string) (map[string]interface{}, error)

UploadCwasm uploads a .cwasm artifact for a wasm app (multipart field "file").

func (*Client) VaultDirectory added in v0.17.0

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

VaultDirectory fetches the active constellation's addressing.

type RegistrySecretResponse added in v0.16.0

type RegistrySecretResponse struct {
	Handle        string `json:"handle"`
	Grant         string `json:"grant"`
	Constellation struct {
		Endpoints         []string `json:"endpoints"`
		MRENCLAVE         string   `json:"mrenclave"`
		AttestationServer string   `json:"attestation_server"`
		OIDCIssuer        string   `json:"oidc_issuer"`
		Threshold         int      `json:"threshold"`
	} `json:"constellation"`
}

RegistrySecretResponse is the platform's response when minting a grant for an app's private-image pull credential: the grant plus the constellation addressing the owner's client needs to push the token material directly.

type VaultDirectory added in v0.17.0

type VaultDirectory struct {
	MRENCLAVE         string
	AttestationServer string
	Endpoints         []string
}

VaultDirectory is the active constellation's addressing — the pin + attestation server + the enabled vault endpoints — from the directory (GET /api/v1/vaults). Used to dial the constellation for in-enclave key operations (sign, get-public).

type VaultExportTarget added in v0.14.0

type VaultExportTarget struct {
	Handle            string   `json:"handle"`
	Endpoints         []string `json:"endpoints"`
	MRENCLAVE         string   `json:"mrenclave"`
	AttestationServer string   `json:"attestation_server"`
	Threshold         int      `json:"threshold"`
	RequireStepUp     bool     `json:"require_step_up"`
}

VaultExportTarget describes where an app's owner-exportable data key lives, so the CLI can export it directly from the vaults over RA-TLS.

type VaultKeyGrantResponse added in v0.14.0

type VaultKeyGrantResponse struct {
	Key           map[string]interface{} `json:"key"`
	Grant         string                 `json:"grant"`
	Constellation struct {
		Endpoints         []string `json:"endpoints"`
		MRENCLAVE         string   `json:"mrenclave"`
		AttestationServer string   `json:"attestation_server"`
		OIDCIssuer        string   `json:"oidc_issuer"`
		Threshold         int      `json:"threshold"`
	} `json:"constellation"`
}

VaultKeyGrantResponse is the platform's response when minting a grant for a new key in a vault: the grant plus the constellation addressing the agent needs to create the material directly on the vaults.

Jump to

Keyboard shortcuts

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