rdeapi

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package rdeapi is the HTTP client for the Bitrise Remote Dev Environments API (https://api.bitrise.io/rde).

This is a sibling of internal/bitriseapi, not a sub-package: the RDE service uses a Bearer authorization header, lives under a different base URL, and emits camelCase JSON (grpc-gateway swagger output) with google.rpc.Status errors. Wire-format DTOs in this package match the backend's shape; the CLI-facing layer in internal/rde converts them into the stable snake_case --output json/yml shape.

Index

Constants

This section is empty.

Variables

View Source
var UserAgent = "bitrise-cli"

UserAgent is sent on every RDE request. cli/cli.go overrides it at startup to include the binary's version. The backend uses this to attribute traffic to CLI vs MCP vs other clients.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode  int
	Message     string
	Violations  []string
	Body        string
	RequestInfo string
}

APIError represents a non-2xx response from the RDE API. Message is the human-readable text extracted from the {"message": "..."} field RDE uses universally; Violations holds field-level validation messages pulled from the gRPC error details (details[].fieldViolations[]), which carry the actionable "why" for 400s (e.g. "missing required input: BUILD_TOKEN"); Body is the raw response body, surfaced only when no structured field was found; RequestInfo is "METHOD /path" so a failure names the endpoint, mirroring bitriseapi.APIError.RequestInfo.

func (*APIError) Error

func (e *APIError) Error() string

type AutoMappedInput

type AutoMappedInput struct {
	SessionInputKey string `json:"sessionInputKey"`
	SavedInputID    string `json:"savedInputId"`
}

AutoMappedInput records a template session input that was auto-filled from the user's saved inputs when MapSavedToSessionInputs=true.

type Client

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

Client is an authenticated HTTP client for the RDE API.

func New

func New(rawBaseURL, token string, opts ...Option) (*Client, error)

New creates a Client authenticated with the given token and base URL. rawBaseURL should be the RDE API root (e.g. https://api.bitrise.io/rde) — resource paths are appended verbatim. Validated via internal/baseurl (https, loopback exempted): this client sends a bearer token on every request, so a misconfigured rde_api_base_url must not be able to send it over plaintext http. The default client has a defaultTimeout deadline; doStream's caller gets streamHTTPClient() instead, for requests that must outlive it.

func (*Client) CompareSessionTemplate

func (c *Client) CompareSessionTemplate(ctx context.Context, workspaceID, sessionID string) (CompareSessionTemplateResponse, error)

CompareSessionTemplate fetches the snapshot-vs-current template diff. Endpoint: GET /v1/workspaces/{workspaceId}/sessions/{sessionId}/template-diff.

func (*Client) CreateSavedInput

func (c *Client) CreateSavedInput(ctx context.Context, req CreateSavedInputRequest) (SavedInput, error)

CreateSavedInput creates a new saved input. Endpoint: POST /v1/saved-inputs.

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, workspaceID string, req CreateSessionRequest) (Session, []AutoMappedInput, error)

CreateSession creates a session from a template. Returns the new session and any session inputs auto-filled from saved inputs (empty unless the request set MapSavedToSessionInputs=true). Endpoint: POST /v1/workspaces/{workspaceId}/sessions.

func (*Client) CreateTemplate

func (c *Client) CreateTemplate(ctx context.Context, workspaceID string, req CreateTemplateRequest) (Template, error)

CreateTemplate creates a new template in the workspace. Endpoint: POST /v1/workspaces/{workspaceId}/templates.

func (*Client) DeleteSavedInput

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

DeleteSavedInput removes a saved input. Endpoint: DELETE /v1/saved-inputs/{savedInputId}.

func (*Client) DeleteSession

func (c *Client) DeleteSession(ctx context.Context, workspaceID, sessionID string) error

DeleteSession permanently deletes a session. Endpoint: DELETE /v1/workspaces/{workspaceId}/sessions/{sessionId}.

func (*Client) DeleteTemplate

func (c *Client) DeleteTemplate(ctx context.Context, workspaceID, templateID string) error

DeleteTemplate removes a template (soft-delete server-side). Endpoint: DELETE /v1/workspaces/{workspaceId}/templates/{templateId}.

func (*Client) DeleteTerminatedSessions

func (c *Client) DeleteTerminatedSessions(ctx context.Context, workspaceID string) (int, error)

DeleteTerminatedSessions removes every terminated (stopped) session in the workspace for the caller and returns the count of deleted sessions. Endpoint: POST /v1/workspaces/{workspaceId}/sessions:delete-terminated.

func (*Client) GetSavedInput

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

GetSavedInput returns a saved input by ID. Endpoint: GET /v1/saved-inputs/{savedInputId}.

Deliberately does not pass include_secrets — see ListSavedInputs.

func (*Client) GetSession

func (c *Client) GetSession(ctx context.Context, workspaceID, sessionID string) (Session, error)

GetSession returns a single session by ID. Endpoint: GET /v1/workspaces/{workspaceId}/sessions/{sessionId}.

func (*Client) GetTemplate

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

GetTemplate returns a single template by ID. Endpoint: GET /v1/workspaces/{workspaceId}/templates/{templateId}.

Deliberately does not pass include_secrets — see ListTemplates.

func (*Client) GetWorkspaceUsage

func (c *Client) GetWorkspaceUsage(ctx context.Context, workspaceID string) (WorkspaceUsage, error)

GetWorkspaceUsage returns the workspace's active-session usage snapshot. Requires the workspace's billing-view permission (workspace owners and billing-managing custom roles); other members get a permission error. Endpoint: GET /v1/workspaces/{workspaceId}/usage.

func (*Client) ListMachineTypes

func (c *Client) ListMachineTypes(ctx context.Context, workspaceID string) ([]MachineType, error)

ListMachineTypes returns every machine type available to the workspace. Endpoint: GET /v1/workspaces/{workspaceId}/machine-types.

func (*Client) ListSavedInputs

func (c *Client) ListSavedInputs(ctx context.Context) ([]SavedInput, error)

ListSavedInputs returns every saved input for the caller. Endpoint: GET /v1/saved-inputs.

Deliberately does not pass include_secrets: the cleartext is unwanted (it would leak into --output json, shell history, and log files). Add the query param here only if a caller genuinely needs cleartext secrets, which would also mean revisiting the masking in internal/rde's mapper.

func (*Client) ListSessionNotifications

func (c *Client) ListSessionNotifications(ctx context.Context, workspaceID, sessionID string, opts ListSessionNotificationsOptions) ([]SessionNotification, error)

ListSessionNotifications returns notifications for a session. Endpoint: GET /v1/workspaces/{workspaceId}/sessions/{sessionId}/notifications.

func (*Client) ListSessions

func (c *Client) ListSessions(ctx context.Context, workspaceID string, labelSelectors []string, scope string) ([]Session, error)

ListSessions returns sessions in the workspace. Each labelSelectors entry is a "key=value" exact-match label filter; multiple selectors are ANDed and passed through verbatim as repeated query params (the backend validates them: key=value form, at most 8, no duplicate keys).

scope selects whose sessions are listed: "mine" (sessions the caller created; also the backend default when empty) or "workspace" (sessions owned by the workspace itself, visible to every member of the workspace). The value is translated to the backend's enum name; anything else is omitted so the backend default applies — mirrors how ListSessionNotifications handles order. Endpoint: GET /v1/workspaces/{workspaceId}/sessions.

func (*Client) ListStacks

func (c *Client) ListStacks(ctx context.Context, workspaceID string) ([]Stack, error)

ListStacks returns every machine stack available to the workspace. Endpoint: GET /v1/workspaces/{workspaceId}/stacks.

func (*Client) ListTemplates

func (c *Client) ListTemplates(ctx context.Context, workspaceID string) ([]Template, error)

ListTemplates returns every template visible in the workspace. Endpoint: GET /v1/workspaces/{workspaceId}/templates.

Deliberately does not pass include_secrets: consumers read metadata only, never secret variable values.

func (*Client) RestoreSession

func (c *Client) RestoreSession(ctx context.Context, workspaceID, sessionID string) (Session, error)

RestoreSession restores a terminated session — the VM is re-created from the persistent disk and the session moves back through STARTING to RUNNING. The legacy /start endpoint is still served as a deprecated alias on the backend but /restore is the canonical name. Endpoint: POST /v1/workspaces/{workspaceId}/sessions/{sessionId}/restore.

func (*Client) SessionCompleteFileUpload

func (c *Client) SessionCompleteFileUpload(ctx context.Context, workspaceID, sessionID string, req CompleteFileUploadRequest) error

SessionCompleteFileUpload finalizes an upload — the backend extracts the archive into the destination folder on the session VM. Endpoint: POST /v1/workspaces/{workspaceId}/sessions/{sessionId}/complete-file-upload.

func (*Client) SessionDownloadFile

func (c *Client) SessionDownloadFile(ctx context.Context, workspaceID, sessionID string, req DownloadFileRequest) (DownloadFileResponse, error)

SessionDownloadFile requests a signed GET URL for a tar.gz of remote files. The actual GET and untar are the caller's responsibility (internal/rde). Endpoint: POST /v1/workspaces/{workspaceId}/sessions/{sessionId}/download-file.

func (*Client) SessionStartFileUpload

func (c *Client) SessionStartFileUpload(ctx context.Context, workspaceID, sessionID string, req StartFileUploadRequest) (StartFileUploadResponse, error)

SessionStartFileUpload initiates an upload to a session, returning a signed PUT URL for the tar.gz archive and an upload ID. The actual PUT and the tar.gz packing are the caller's responsibility (internal/rde). Endpoint: POST /v1/workspaces/{workspaceId}/sessions/{sessionId}/start-file-upload.

func (*Client) StreamSessionLogs

func (c *Client) StreamSessionLogs(ctx context.Context, workspaceID, sessionID string, stage LogStage, idleTimeout time.Duration, fn func(LogChunk) error) error

StreamSessionLogs opens the server-streaming log endpoint for one stage of a session and invokes fn for every non-empty content chunk, in order.

Endpoint: GET /v1/workspaces/{workspaceId}/sessions/{sessionId}/logs/{stage} where stage is LogStageWarmup or LogStageMain. The stream replays the stage log from the start, then continues live. The backend never sends EOF when the stage's script finishes — it holds the connection open with minute-interval heartbeats — so callers control how long to listen:

  • idleTimeout <= 0: stream until the connection actually closes or ctx is cancelled (Ctrl-C). Use for a live "follow".
  • idleTimeout > 0: return cleanly once no new content has arrived for that long. The replayed backlog arrives in a burst, so this delivers the whole log-so-far and then exits ("print what's there, don't wait").

Heartbeat/empty frames are skipped and do not count as content. A mid-stream {"error":...} frame is surfaced as an error. A ctx cancelled via context.Canceled (Ctrl-C) is treated as a clean end of stream and returns nil; a ctx that ends via context.DeadlineExceeded is surfaced as an error, since silently returning nil would let a caller mistake a timeout for a finished log. Pre-stream failures come back as *APIError (e.g. 404 = "logs not available yet").

func (*Client) TerminateSession

func (c *Client) TerminateSession(ctx context.Context, workspaceID, sessionID string) (Session, error)

TerminateSession terminates a running session (stops the VM, preserving the session for later restart). The legacy /stop endpoint is still served as a deprecated alias on the backend but the canonical name is /terminate. Endpoint: POST /v1/workspaces/{workspaceId}/sessions/{sessionId}/terminate.

func (*Client) UpdateSavedInput

func (c *Client) UpdateSavedInput(ctx context.Context, id string, req UpdateSavedInputRequest) (SavedInput, error)

UpdateSavedInput patches a saved input's value and/or secret flag. Endpoint: PATCH /v1/saved-inputs/{savedInputId}.

func (*Client) UpdateSession

func (c *Client) UpdateSession(ctx context.Context, workspaceID, sessionID string, req UpdateSessionRequest) (Session, error)

UpdateSession patches name, description, or auto-terminate minutes. Endpoint: PATCH /v1/workspaces/{workspaceId}/sessions/{sessionId}.

func (*Client) UpdateTemplate

func (c *Client) UpdateTemplate(ctx context.Context, workspaceID, templateID string, req UpdateTemplateRequest) (Template, error)

UpdateTemplate patches an existing template. See UpdateTemplateRequest for the UpdateXxx-boolean semantics around the array fields. Endpoint: PATCH /v1/workspaces/{workspaceId}/templates/{templateId}.

type CompareSessionTemplateResponse

type CompareSessionTemplateResponse struct {
	Snapshot            *TemplateConfig `json:"snapshot,omitempty"`
	Current             *TemplateConfig `json:"current,omitempty"`
	ChangedVariableKeys []string        `json:"changedVariableKeys,omitempty"`
}

CompareSessionTemplateResponse is the wire shape of /template-diff.

type CompleteFileUploadRequest

type CompleteFileUploadRequest struct {
	UploadID          string `json:"uploadId"`
	DestinationFolder string `json:"destinationFolder"`
}

CompleteFileUploadRequest is the POST body for /complete-file-upload.

type CreateSavedInputRequest

type CreateSavedInputRequest struct {
	Key      string `json:"key"`
	Value    string `json:"value"`
	IsSecret bool   `json:"isSecret,omitempty"`
}

CreateSavedInputRequest is the POST body for creating a saved input.

type CreateSessionRequest

type CreateSessionRequest struct {
	Name                    string              `json:"name"`
	Description             string              `json:"description,omitempty"`
	TemplateID              string              `json:"templateId,omitempty"`
	StackID                 string              `json:"stackId,omitempty"`
	MachineType             string              `json:"machineType,omitempty"`
	SessionInputs           []SessionInputValue `json:"sessionInputs,omitempty"`
	EnabledFeatureFlagNames []string            `json:"enabledFeatureFlagNames,omitempty"`
	Cluster                 string              `json:"cluster,omitempty"`
	AIPrompt                string              `json:"aiPrompt,omitempty"`
	AutoTerminateMinutes    *int                `json:"autoTerminateMinutes,omitempty"`
	MapSavedToSessionInputs bool                `json:"mapSavedToSessionInputs,omitempty"`
	// Labels is arbitrary key=value metadata attached to the session. Sent
	// verbatim; the backend enforces the constraints (at most 32 entries;
	// keys 1-63 chars of [a-zA-Z0-9._/-] starting and ending alphanumeric;
	// values 1-255 bytes of [a-zA-Z0-9._/:+-] with no positional rules;
	// the "bitrise.io/" key prefix is reserved for system-owned labels and
	// rejected on writes).
	Labels map[string]string `json:"labels,omitempty"`
}

CreateSessionRequest is the POST body for creating a session. TemplateID is optional: omit it (and supply StackID + MachineType) to create a session without a template. When a template is given, StackID / MachineType optionally override the template's defaults for this session.

type CreateTemplateRequest

type CreateTemplateRequest struct {
	Name              string                   `json:"name"`
	Description       string                   `json:"description,omitempty"`
	StackID           string                   `json:"stackId"`
	MachineType       string                   `json:"machineType"`
	WorkingDirectory  string                   `json:"workingDirectory,omitempty"`
	StartupScript     string                   `json:"startupScript,omitempty"`
	WarmupScript      string                   `json:"warmupScript,omitempty"`
	TemplateVariables []TemplateVariableCreate `json:"templateVariables,omitempty"`
	SessionInputs     []SessionInputCreate     `json:"sessionInputs,omitempty"`
	FeatureFlags      []FeatureFlagCreate      `json:"featureFlags,omitempty"`
	WorkspaceLinks    []WorkspaceLinkCreate    `json:"workspaceLinks,omitempty"`
}

CreateTemplateRequest is the POST body for creating a template.

type DownloadFileRequest

type DownloadFileRequest struct {
	SourcePath           string `json:"sourcePath"`
	OnlyContentsOfFolder bool   `json:"onlyContentsOfFolder,omitempty"`
}

DownloadFileRequest is the POST body for /download-file.

type DownloadFileResponse

type DownloadFileResponse struct {
	SignedURL string `json:"signedUrl"`
}

DownloadFileResponse carries a signed GET URL for the tar.gz archive.

type FeatureFlag

type FeatureFlag struct {
	ID          string `json:"id,omitempty"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

FeatureFlag is a toggleable feature on a template.

type FeatureFlagCreate

type FeatureFlagCreate struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

FeatureFlagCreate is the create-time shape of a feature flag.

type ListSessionNotificationsOptions

type ListSessionNotificationsOptions struct {
	CreatedBefore string // RFC3339; only notifications created strictly before this
	CreatedAfter  string // RFC3339; only notifications created strictly after this
	Limit         int
	Order         string // "asc" or "desc"; empty means server default (desc)
}

ListSessionNotificationsOptions filters the notifications list. All fields are optional. Server defaults: limit=50, order=desc.

type LogChunk

type LogChunk struct {
	LogContent       string `json:"logContent"`
	HeartbeatMessage bool   `json:"heartbeatMessage"`
}

LogChunk is one frame of a session log stream. HeartbeatMessage frames carry empty LogContent and exist only to keep the connection alive; callers skip them.

type LogStage

type LogStage string

LogStage selects which stage's log to stream.

const (
	LogStageWarmup LogStage = "1"
	LogStageMain   LogStage = "2"
)

type MachineType

type MachineType struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	ClusterName string `json:"clusterName,omitempty"`
	// IsDefault is set by the backend on the deployment's default machine type.
	IsDefault bool   `json:"isDefault,omitempty"`
	Title     string `json:"title,omitempty"`
	CPU       string `json:"cpu,omitempty"`
	RAM       string `json:"ram,omitempty"`
	OS        string `json:"os,omitempty"`
}

MachineType is a machine size available for templates/sessions. Name is the contract (what templates/sessions store); Title/CPU/RAM are human-friendly display metadata and may be empty when the backend has none.

type Option

type Option func(*Client)

Option configures a Client.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient replaces the default HTTP client (useful for tests).

type PlatformUsage

type PlatformUsage struct {
	SessionCount int32 `json:"sessionCount"`
	VCPU         int32 `json:"vcpu"`
	MemoryGB     int32 `json:"memoryGb"`
}

PlatformUsage aggregates active sessions on one OS platform. The backend omits zero-valued fields from the JSON, so absent means 0.

type SavedInput

type SavedInput struct {
	ID        string `json:"id"`
	Key       string `json:"key"`
	Value     string `json:"value,omitempty"`
	IsSecret  bool   `json:"isSecret,omitempty"`
	CreatedAt string `json:"createdAt,omitempty"`
	UpdatedAt string `json:"updatedAt,omitempty"`
}

SavedInput is a user-scoped credential/value reusable across sessions.

Secret values (IsSecret=true) are only returned by the read endpoints (ListSavedInputs / GetSavedInput) when a request opts in with include_secrets=true. The CLI intentionally never sets that flag — it has no use for the cleartext, and internal/rde masks any secret value before handing saved inputs to renderers. So Value is empty for secret inputs on reads (create/update may still echo the just-submitted value back).

type Session

type Session struct {
	ID                          string                   `json:"id"`
	Name                        string                   `json:"name"`
	Description                 string                   `json:"description,omitempty"`
	Status                      string                   `json:"status,omitempty"`
	TemplateID                  string                   `json:"templateId,omitempty"`
	TemplateDeleted             bool                     `json:"templateDeleted,omitempty"`
	TemplateOutdated            bool                     `json:"templateOutdated,omitempty"`
	TemplateSnapshot            *SessionTemplateSnapshot `json:"templateSnapshot,omitempty"`
	AgentSessionStatus          string                   `json:"agentSessionStatus,omitempty"`
	AgentSessionStatusUpdatedAt string                   `json:"agentSessionStatusUpdatedAt,omitempty"`
	AIEnabled                   bool                     `json:"aiEnabled,omitempty"`
	AIConfigured                bool                     `json:"aiConfigured,omitempty"`
	AIPrompt                    string                   `json:"aiPrompt,omitempty"`
	AutoTerminateAt             string                   `json:"autoTerminateAt,omitempty"`
	AutoTerminateMinutes        int                      `json:"autoTerminateMinutes,omitempty"`
	SSHAddress                  string                   `json:"sshAddress,omitempty"`
	SSHPassword                 string                   `json:"sshPassword,omitempty"`
	SSHConnectionOpen           bool                     `json:"sshConnectionOpen,omitempty"`
	VNCAddress                  string                   `json:"vncAddress,omitempty"`
	VNCUsername                 string                   `json:"vncUsername,omitempty"`
	VNCPassword                 string                   `json:"vncPassword,omitempty"`
	PersistentDiskStatus        string                   `json:"persistentDiskStatus,omitempty"`
	Labels                      map[string]string        `json:"labels,omitempty"`
	// OwnerType says who owns the session: "user" (the creating user; the
	// default) or "workspace" (the workspace itself — such sessions are
	// visible to every member of the workspace). The backend may add more
	// owner kinds over time, so treat unknown values as opaque.
	OwnerType string `json:"ownerType,omitempty"`
	// OwnerID is the owner's identifier, typed by OwnerType: the owning
	// user's ID for "user", the workspace slug for "workspace".
	OwnerID   string `json:"ownerId,omitempty"`
	CreatedAt string `json:"createdAt,omitempty"`
	UpdatedAt string `json:"updatedAt,omitempty"`
}

Session is the wire-format session record returned by the RDE API.

type SessionInputCreate

type SessionInputCreate struct {
	Key            string `json:"key"`
	Description    string `json:"description,omitempty"`
	Required       bool   `json:"required,omitempty"`
	DefaultValue   string `json:"defaultValue,omitempty"`
	ExposeAsEnvVar bool   `json:"exposeAsEnvVar,omitempty"`
}

SessionInputCreate is the create-time shape of a session input definition.

type SessionInputDef

type SessionInputDef struct {
	ID             string `json:"id,omitempty"`
	Key            string `json:"key"`
	Description    string `json:"description,omitempty"`
	Required       bool   `json:"required,omitempty"`
	DefaultValue   string `json:"defaultValue,omitempty"`
	ExposeAsEnvVar bool   `json:"exposeAsEnvVar,omitempty"`
}

SessionInputDef defines an input the template prompts for at session creation time. (Distinct from SessionInputValue, which is the user's answer in a CreateSessionRequest.)

type SessionInputValue

type SessionInputValue struct {
	Key          string `json:"key"`
	Value        string `json:"value,omitempty"`
	IsSecret     bool   `json:"isSecret,omitempty"`
	SavedInputID string `json:"savedInputId,omitempty"`
}

SessionInputValue provides a value for a session input when creating a session. Either Value (with optional IsSecret) OR SavedInputID is used.

type SessionNotification

type SessionNotification struct {
	ID        string `json:"id"`
	SessionID string `json:"sessionId,omitempty"`
	Title     string `json:"title,omitempty"`
	Body      string `json:"body,omitempty"`
	Type      string `json:"type,omitempty"`
	CreatedAt string `json:"createdAt,omitempty"`
}

SessionNotification is a persisted notification from a session VM (agent stop/idle/permission prompts, etc.).

type SessionTemplateSnapshot

type SessionTemplateSnapshot struct {
	TemplateName string `json:"templateName,omitempty"`
	StackID      string `json:"stackId,omitempty"`
	// Image is the resolved image id, retained only as a read fallback for
	// snapshots taken before stackId was populated.
	Image            string          `json:"image,omitempty"`
	MachineType      string          `json:"machineType,omitempty"`
	WorkingDirectory string          `json:"workingDirectory,omitempty"`
	HasStartupScript bool            `json:"hasStartupScript,omitempty"`
	HasWarmupScript  bool            `json:"hasWarmupScript,omitempty"`
	SessionInputs    []SnapshotInput `json:"sessionInputs,omitempty"`
	FeatureFlags     []SnapshotFlag  `json:"featureFlags,omitempty"`
	WorkspaceLinks   []SnapshotLink  `json:"workspaceLinks,omitempty"`
	UpdatedAt        string          `json:"updatedAt,omitempty"`
}

SessionTemplateSnapshot is the template config snapshotted at session creation time.

type SnapshotFlag

type SnapshotFlag struct {
	Name    string `json:"name"`
	Enabled bool   `json:"enabled,omitempty"`
}

SnapshotFlag is a feature-flag state captured at session creation.

type SnapshotInput

type SnapshotInput struct {
	Key            string `json:"key"`
	Value          string `json:"value,omitempty"`
	IsSecret       bool   `json:"isSecret,omitempty"`
	ExposeAsEnvVar bool   `json:"exposeAsEnvVar,omitempty"`
}

SnapshotInput is a session-input value captured at session creation.

Secret values (IsSecret=true) are only returned when a request opts in with include_secrets=true, which this client never sets; internal/rde masks the value again as defense-in-depth in case the backend default ever changes.

type SnapshotLink struct {
	Label      string `json:"label,omitempty"`
	FolderPath string `json:"folderPath,omitempty"`
	SortOrder  int    `json:"sortOrder,omitempty"`
}

SnapshotLink is a workspace link captured at session creation.

type Stack

type Stack struct {
	ID           string `json:"id"`
	Title        string `json:"title,omitempty"`
	Description  string `json:"description,omitempty"`
	OS           string `json:"os,omitempty"`
	OSVersion    int32  `json:"osVersion,omitempty"`
	Status       string `json:"status,omitempty"`
	XcodeVersion string `json:"xcodeVersion,omitempty"`
	// IsDefault is set by the backend on the deployment's default stack.
	IsDefault bool `json:"isDefault,omitempty"`
	// ClusterNames are the clusters where this stack can be provisioned.
	ClusterNames []string `json:"clusterNames,omitempty"`
	// DescriptionLink points at the stack's pre-installed tools / system report.
	DescriptionLink string `json:"descriptionLink,omitempty"`
}

Stack is a machine stack available for templates/sessions. The id is the stable contract stored on a template/session; the remaining fields are human-friendly catalog metadata.

type StartFileUploadRequest

type StartFileUploadRequest struct {
	DestinationFolder string `json:"destinationFolder"`
}

StartFileUploadRequest is the POST body for /start-file-upload.

type StartFileUploadResponse

type StartFileUploadResponse struct {
	SignedURL string `json:"signedUrl"`
	UploadID  string `json:"uploadId"`
}

StartFileUploadResponse is the response from /start-file-upload: a signed PUT URL plus the upload identifier to send back to complete-file-upload.

type Template

type Template struct {
	ID          string `json:"id"`
	WorkspaceID string `json:"workspaceId,omitempty"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	StackID     string `json:"stackId,omitempty"`
	// Image is retained only as a read fallback for templates created before
	// stackId was populated.
	Image             string             `json:"image,omitempty"`
	MachineType       string             `json:"machineType,omitempty"`
	WorkingDirectory  string             `json:"workingDirectory,omitempty"`
	StartupScript     string             `json:"startupScript,omitempty"`
	WarmupScript      string             `json:"warmupScript,omitempty"`
	CreatedByEmail    string             `json:"createdByEmail,omitempty"`
	TemplateVariables []TemplateVariable `json:"templateVariables,omitempty"`
	SessionInputs     []SessionInputDef  `json:"sessionInputs,omitempty"`
	FeatureFlags      []FeatureFlag      `json:"featureFlags,omitempty"`
	WorkspaceLinks    []WorkspaceLink    `json:"workspaceLinks,omitempty"`
	CreatedAt         string             `json:"createdAt,omitempty"`
	UpdatedAt         string             `json:"updatedAt,omitempty"`
}

Template is the wire-format template record.

type TemplateConfig

type TemplateConfig struct {
	TemplateName string `json:"templateName,omitempty"`
	StackID      string `json:"stackId,omitempty"`
	// Image is retained only as a read fallback for configs from before
	// stackId was populated.
	Image             string                   `json:"image,omitempty"`
	MachineType       string                   `json:"machineType,omitempty"`
	WorkingDirectory  string                   `json:"workingDirectory,omitempty"`
	StartupScript     string                   `json:"startupScript,omitempty"`
	WarmupScript      string                   `json:"warmupScript,omitempty"`
	SessionInputs     []TemplateConfigInput    `json:"sessionInputs,omitempty"`
	FeatureFlags      []TemplateConfigFlag     `json:"featureFlags,omitempty"`
	TemplateVariables []TemplateConfigVariable `json:"templateVariables,omitempty"`
	WorkspaceLinks    []SnapshotLink           `json:"workspaceLinks,omitempty"`
	UpdatedAt         string                   `json:"updatedAt,omitempty"`
}

TemplateConfig is the diff-endpoint view of a template — same fields on both sides of the diff (snapshot vs current). Deliberately distinct from Template: the diff uses its own *Config-variant sub-types, and secret values are always stripped.

type TemplateConfigFlag

type TemplateConfigFlag struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Enabled     bool   `json:"enabled,omitempty"`
}

TemplateConfigFlag is a feature flag with its default state.

type TemplateConfigInput

type TemplateConfigInput struct {
	Key            string `json:"key"`
	Description    string `json:"description,omitempty"`
	Required       bool   `json:"required,omitempty"`
	DefaultValue   string `json:"defaultValue,omitempty"`
	ExposeAsEnvVar bool   `json:"exposeAsEnvVar,omitempty"`
	IsSecret       bool   `json:"isSecret,omitempty"`
}

TemplateConfigInput is a session-input definition for diff purposes.

type TemplateConfigVariable

type TemplateConfigVariable struct {
	Key            string `json:"key"`
	IsSecret       bool   `json:"isSecret,omitempty"`
	ExposeAsEnvVar bool   `json:"exposeAsEnvVar,omitempty"`
}

TemplateConfigVariable is a template variable's metadata (no value).

type TemplateVariable

type TemplateVariable struct {
	ID             string `json:"id,omitempty"`
	Key            string `json:"key"`
	Value          string `json:"value,omitempty"`
	IsSecret       bool   `json:"isSecret,omitempty"`
	ExposeAsEnvVar bool   `json:"exposeAsEnvVar,omitempty"`
}

TemplateVariable is a baked-in template variable.

Secret values (IsSecret=true) are only returned by the backend when a request opts in with include_secrets=true. The CLI intentionally never sets that flag on template reads, and internal/rde masks any secret value again as defense-in-depth in case the backend default ever changes.

type TemplateVariableCreate

type TemplateVariableCreate struct {
	Key            string `json:"key"`
	Value          string `json:"value,omitempty"`
	IsSecret       bool   `json:"isSecret,omitempty"`
	ExposeAsEnvVar bool   `json:"exposeAsEnvVar,omitempty"`
}

TemplateVariableCreate is the create-time shape of a template variable; distinct from TemplateVariable because no ID is sent — the server assigns one.

type UpdateSavedInputRequest

type UpdateSavedInputRequest struct {
	Value    *string `json:"value,omitempty"`
	IsSecret *bool   `json:"isSecret,omitempty"`
}

UpdateSavedInputRequest is the PATCH body. Pointer fields preserve the "unset, leave alone" semantics — only fields with non-nil values are sent.

type UpdateSessionRequest

type UpdateSessionRequest struct {
	Name                 *string           `json:"name,omitempty"`
	Description          *string           `json:"description,omitempty"`
	AutoTerminateMinutes *int              `json:"autoTerminateMinutes,omitempty"`
	Labels               map[string]string `json:"labels,omitempty"`
	RemoveLabels         []string          `json:"removeLabels,omitempty"`
}

UpdateSessionRequest is the PATCH body for updating a session. Pointer fields let the caller distinguish "unset, leave alone" from "set to empty/zero". Labels are merged into the session's existing labels (existing keys overwritten, other keys untouched) with the same constraints as CreateSessionRequest.Labels; RemoveLabels lists keys to delete (unknown keys ignored; when a key appears in both, the removal wins server-side).

type UpdateTemplateRequest

type UpdateTemplateRequest struct {
	Name             *string `json:"name,omitempty"`
	Description      *string `json:"description,omitempty"`
	StackID          *string `json:"stackId,omitempty"`
	MachineType      *string `json:"machineType,omitempty"`
	WorkingDirectory *string `json:"workingDirectory,omitempty"`
	StartupScript    *string `json:"startupScript,omitempty"`
	WarmupScript     *string `json:"warmupScript,omitempty"`

	TemplateVariables       []TemplateVariableCreate `json:"templateVariables,omitempty"`
	UpdateTemplateVariables bool                     `json:"updateTemplateVariables,omitempty"`
	SessionInputs           []SessionInputCreate     `json:"sessionInputs,omitempty"`
	UpdateSessionInputs     bool                     `json:"updateSessionInputs,omitempty"`
	FeatureFlags            []FeatureFlagCreate      `json:"featureFlags,omitempty"`
	UpdateFeatureFlags      bool                     `json:"updateFeatureFlags,omitempty"`
	WorkspaceLinks          []WorkspaceLinkCreate    `json:"workspaceLinks,omitempty"`
	UpdateWorkspaceLinks    bool                     `json:"updateWorkspaceLinks,omitempty"`
}

UpdateTemplateRequest is the PATCH body. The four UpdateXxx booleans are required when an array field should replace the server's existing list — an array with its flag unset is treated as "no change", not "clear it".

type UsageTotals

type UsageTotals struct {
	Linux   *PlatformUsage `json:"linux"`
	Macos   *PlatformUsage `json:"macos"`
	Unknown *PlatformUsage `json:"unknown"`
}

UsageTotals splits active-session usage by OS platform. Buckets are pointers because the backend may omit an empty bucket object entirely.

type UserUsage

type UserUsage struct {
	UserID      string       `json:"userId"`
	UserSlug    string       `json:"userSlug"`
	Email       string       `json:"email"`
	Username    string       `json:"username"`
	IsWorkspace bool         `json:"isWorkspace"`
	Totals      *UsageTotals `json:"totals"`
}

UserUsage is one row of the per-user usage breakdown. The workspace-owned bucket row (IsWorkspace) carries no user identity.

type WorkspaceLink struct {
	Label      string `json:"label,omitempty"`
	FolderPath string `json:"folderPath,omitempty"`
	SortOrder  int    `json:"sortOrder,omitempty"`
}

WorkspaceLink is an IDE folder shortcut bundled with a template.

type WorkspaceLinkCreate

type WorkspaceLinkCreate struct {
	Label           string `json:"label,omitempty"`
	FolderPath      string `json:"folderPath,omitempty"`
	FeatureFlagName string `json:"featureFlagName,omitempty"`
}

WorkspaceLinkCreate is the create-time shape of a workspace link.

type WorkspaceUsage

type WorkspaceUsage struct {
	Totals *UsageTotals `json:"totals"`
	Users  []UserUsage  `json:"users"`
	// UnknownMachineTypeCount is the number of active sessions whose machine
	// type had no resolvable vCPU/RAM spec; they contribute 0 to the sums, so
	// totals may undercount when this is non-zero.
	UnknownMachineTypeCount int32 `json:"unknownMachineTypeCount"`
}

WorkspaceUsage is the workspace usage report: a point-in-time snapshot of the sessions currently consuming resources, split by OS and by user.

Jump to

Keyboard shortcuts

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