client

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 22 Imported by: 1 module, 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 client owns authenticated API transport. Only invoice downloads follow redirects, dropping credentials when leaving the original origin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJSON added in v0.9.0

func DecodeJSON(data []byte) (any, error)

DecodeJSON parses exactly one JSON value in a single pass, keeping numbers exact.

Types

type APIResponse added in v0.9.0

type APIResponse struct {
	Protocol, Status string
	Code             int
	Headers          http.Header
	Body             []byte
}

type ArtifactRecord

type ArtifactRecord struct {
	Fields  map[string]any
	RawJSON json.RawMessage
}

ArtifactRecord retains the server's field order for human-readable metadata.

type AuditPage

type AuditPage struct {
	Page
	EventData []json.RawMessage
}

type Availability added in v0.9.0

type Availability struct {
	Repositories []string `json:"repositories,omitempty"`
	Environments []string `json:"environments,omitempty"`
	Branches     []string `json:"branches,omitempty"`
	Workflows    []string `json:"workflows,omitempty"`
	PrivateOnly  bool     `json:"private_only,omitempty"`
}

Availability contains the selector categories understood by the secret manager. Empty categories are unrestricted; values within each category are alternatives.

type Client

type Client struct {
	Config    config.Config
	HTTP      *http.Client
	UserAgent string
	Trace     io.Writer
	Timings   io.Writer
}

func New

func New(cfg config.Config, transport *http.Client, userAgent string) *Client

New copies the HTTP client so composing a command cannot change another client's redirect policy or timeout. Credentials are sent only to Config.Host.

func (*Client) AccessToken

func (c *Client) AccessToken(ctx context.Context, path string) (map[string]any, error)

func (*Client) AccessTokens

func (c *Client) AccessTokens(ctx context.Context, path string, query url.Values) (Page, error)

func (*Client) Artifact

func (c *Client) Artifact(ctx context.Context, path string) (ArtifactRecord, error)

func (*Client) Artifacts

func (c *Client) Artifacts(ctx context.Context, path string, query url.Values) (Page, error)

func (*Client) AuditEvents

func (c *Client) AuditEvents(ctx context.Context, org string, query url.Values) (AuditPage, error)

func (*Client) BillingSettings

func (c *Client) BillingSettings(ctx context.Context, path string) (map[string]any, error)

func (*Client) BillingSummary

func (c *Client) BillingSummary(ctx context.Context, path string) (map[string]any, error)

func (*Client) BuilderSession added in v0.12.0

func (c *Client) BuilderSession(ctx context.Context, path string) (map[string]any, error)

func (*Client) BuilderSessions added in v0.12.0

func (c *Client) BuilderSessions(ctx context.Context, path string, query url.Values) (Page, error)

func (*Client) CacheEntries

func (c *Client) CacheEntries(ctx context.Context, org, repo string, query url.Values) (Page, error)

func (*Client) CacheUsage

func (c *Client) CacheUsage(ctx context.Context, org, repo string) (map[string]any, error)

func (*Client) CallAPI added in v0.9.0

func (c *Client) CallAPI(ctx context.Context, method, path string, body []byte, headers http.Header) (APIResponse, error)

func (*Client) CancelRun

func (c *Client) CancelRun(ctx context.Context, org, id string) (map[string]any, error)

func (*Client) ConfigurationMetadataRequest added in v0.9.0

func (c *Client) ConfigurationMetadataRequest(ctx context.Context, method, path string, body any, target any) error

ConfigurationMetadataRequest opts into parsed refusal details. Callers must use it only for requests that do not carry secret or variable values.

func (*Client) ConfigurationRequest added in v0.9.0

func (c *Client) ConfigurationRequest(ctx context.Context, method, path string, body any, target any) error

ConfigurationRequest deliberately disables diagnostics and transport replay. A value PUT appends a version, so retrying it is not an idempotent replacement. Error details are hidden by default because proxies can echo plaintext. Raw payloads and diagnostics are never exposed.

func (*Client) ConfigureSAML

func (c *Client) ConfigureSAML(ctx context.Context, path string, metadata []byte, query url.Values) (map[string]any, error)

func (*Client) CreateBuilderSession added in v0.12.0

func (c *Client) CreateBuilderSession(ctx context.Context, path string, request map[string]any) (map[string]any, error)

func (*Client) CreateFirewallRule

func (c *Client) CreateFirewallRule(ctx context.Context, path string, body map[string]any) (map[string]any, error)

func (*Client) CreateGitLabRunner

func (c *Client) CreateGitLabRunner(ctx context.Context, token string, body map[string]any) (string, string, error)

CreateGitLabRunner sends the personal token only to GitLab's fixed origin. It does not inherit API authentication, tracing, cookies, or redirects.

func (*Client) CreateOrganization

func (c *Client) CreateOrganization(ctx context.Context, name string) (map[string]any, error)

func (*Client) CreatePullRequestComment added in v0.9.0

func (c *Client) CreatePullRequestComment(ctx context.Context, org, repo string, number int, body string) (map[string]any, error)

CreatePullRequestComment posts a general comment on the whole pull request.

func (*Client) CreateReviewThread added in v0.9.0

func (c *Client) CreateReviewThread(ctx context.Context, org, repo string, number int, body string, anchor ReviewAnchor) (thread, comment map[string]any, err error)

CreateReviewThread starts an inline review thread and returns it with its first comment, which carries the comment's own GitHub publication status.

func (*Client) CreateVM

func (c *Client) CreateVM(ctx context.Context, path string, request map[string]any, rules *[]any, bootstrap map[string]any) (map[string]any, error)

func (*Client) DataList added in v0.12.0

func (c *Client) DataList(ctx context.Context, path string, query url.Values) (Page, error)

DataList reads one page of a route that answers {"data": [...], "pagination": {...}}.

func (*Client) DataRecord added in v0.12.0

func (c *Client) DataRecord(ctx context.Context, method, path string, body any) (map[string]any, error)

DataRecord sends a request to a route that wraps its object as {"data": {...}} and returns that object.

func (*Client) DeleteBuilderSession added in v0.12.0

func (c *Client) DeleteBuilderSession(ctx context.Context, path string) (map[string]any, error)

DeleteBuilderSession returns the response envelope, or nil when the API sends no body.

func (*Client) DeleteFirewallRule

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

func (*Client) DeleteVM

func (c *Client) DeleteVM(ctx context.Context, path string) (map[string]any, error)

func (*Client) DispatchAvreaCIWorkflow added in v0.10.0

func (c *Client) DispatchAvreaCIWorkflow(ctx context.Context, org, repo, workflow, ref, key string, inputs map[string]string) (map[string]any, error)

DispatchAvreaCIWorkflow outlasts the 45 seconds the API may hold an Avrea CI dispatch. A request that repeats key returns the first one's receipt.

func (*Client) DispatchWorkflow

func (c *Client) DispatchWorkflow(ctx context.Context, org, repo, file, ref string, inputs map[string]string) (map[string]any, error)

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, path string, body any) (map[string]any, error)

func (*Client) Download

func (c *Client) Download(ctx context.Context, path string) (io.ReadCloser, error)

Download streams an authenticated response, with an inactivity timeout rather than a whole-file deadline. The caller must close the body. Redirects are refused even if the supplied transport allows them.

func (*Client) DownloadDecoded

func (c *Client) DownloadDecoded(ctx context.Context, path string) (io.ReadCloser, error)

DownloadDecoded supports opaque analysis artifacts with the same compression negotiation as Python. The decoded bytes stream without the JSON size limit.

func (*Client) DownloadInvoice

func (c *Client) DownloadInvoice(ctx context.Context, path string) (io.ReadCloser, error)

DownloadInvoice follows PDF redirects without forwarding API credentials outside the original origin. Other API and artifact requests refuse redirects.

func (*Client) EmailDomains

func (c *Client) EmailDomains(ctx context.Context, path string) (Page, error)

func (*Client) EnforceSAML

func (c *Client) EnforceSAML(ctx context.Context, path string, enforce bool) (map[string]any, error)

func (*Client) ExportFirewall added in v0.8.0

func (c *Client) ExportFirewall(ctx context.Context, path string) (FirewallPolicy, error)

func (*Client) FeatureFlag

func (c *Client) FeatureFlag(ctx context.Context, org, key string) (map[string]any, error)

func (*Client) Feedback added in v0.8.0

func (c *Client) Feedback(ctx context.Context, id string) (map[string]any, error)

func (*Client) FirewallFlows

func (c *Client) FirewallFlows(ctx context.Context, path string, query url.Values) (map[string]any, error)

func (*Client) FirewallRules

func (c *Client) FirewallRules(ctx context.Context, path string) (Page, error)

func (*Client) GenerateSBOM

func (c *Client) GenerateSBOM(ctx context.Context, path string, body map[string]any) (map[string]any, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, query url.Values) (map[string]any, error)

func (*Client) GitClusters

func (c *Client) GitClusters(ctx context.Context, org string, query url.Values) (Page, error)

func (*Client) GitMirror

func (c *Client) GitMirror(ctx context.Context, method, path string, body any) (map[string]any, error)

func (*Client) GitToken

func (c *Client) GitToken(ctx context.Context, repository string) (map[string]any, error)

func (*Client) Groups added in v0.9.0

func (c *Client) Groups(ctx context.Context, org string, query url.Values) (Page, error)

func (*Client) Health

func (c *Client) Health(ctx context.Context) (map[string]any, error)

func (*Client) ImportFirewall added in v0.8.0

func (c *Client) ImportFirewall(ctx context.Context, path, mode string, policy FirewallPolicy, revision string) error

func (*Client) Installations

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

func (*Client) Invoice

func (c *Client) Invoice(ctx context.Context, path string) (map[string]any, error)

func (*Client) Invoices

func (c *Client) Invoices(ctx context.Context, path string, query url.Values) (Page, error)

func (*Client) Job

func (c *Client) Job(ctx context.Context, org, id string, query url.Values) (map[string]any, error)

func (*Client) JobAggregates

func (c *Client) JobAggregates(ctx context.Context, org string, query url.Values) (Page, error)

func (*Client) JobMetrics

func (c *Client) JobMetrics(ctx context.Context, org, id, source string, query url.Values) (map[string]any, error)

func (*Client) Jobs

func (c *Client) Jobs(ctx context.Context, org string, query url.Values) (Page, error)

func (*Client) MintAccessToken

func (c *Client) MintAccessToken(ctx context.Context, path string, body map[string]any) (any, error)

MintAccessToken keeps the successful raw JSON until the one-time credential is delivered. An unrelated malformed summary field must not discard it.

func (*Client) MirrorPullRequest added in v0.9.0

func (c *Client) MirrorPullRequest(ctx context.Context, org, repo string, number int) (map[string]any, error)

MirrorPullRequest reads one pull request's metadata, including the head and base commits that inline comments anchor to.

func (*Client) MirrorSession

func (c *Client) MirrorSession(ctx context.Context, repository string) (map[string]any, error)

func (*Client) MutateEmailDomain

func (c *Client) MutateEmailDomain(ctx context.Context, path string, body any) (map[string]any, error)

func (*Client) OpenObservability

func (c *Client) OpenObservability(ctx context.Context, path, signal string, timeout time.Duration) (*ObservabilityStream, error)

func (*Client) OrganizationMembers

func (c *Client) OrganizationMembers(ctx context.Context, org string) (Page, error)

OrganizationMembers returns the first page of an organization's members. The CLI follows cursors with DataList.

func (*Client) Organizations

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

func (*Client) PaymentMethods

func (c *Client) PaymentMethods(ctx context.Context, path string) (Page, error)

func (*Client) PostList added in v0.12.0

func (c *Client) PostList(ctx context.Context, path string, body any) (Page, error)

PostList sends a read that carries its input in a POST body, such as an email address kept out of URLs, and returns the listing it answers.

func (*Client) PreviewFirewallImport added in v0.8.0

func (c *Client) PreviewFirewallImport(ctx context.Context, path, mode string, policy FirewallPolicy) (FirewallImportPreview, error)

func (*Client) PublicMirror

func (c *Client) PublicMirror(ctx context.Context, path string) (map[string]any, error)

func (*Client) PublicMirrorRequest

func (c *Client) PublicMirrorRequest(ctx context.Context, method, path string, body any, fallbackID string) (map[string]any, error)

func (*Client) PublicMirrorRequests

func (c *Client) PublicMirrorRequests(ctx context.Context, path string) (Page, error)

func (*Client) PullRequests

func (c *Client) PullRequests(ctx context.Context, org string, query url.Values) (Page, error)

func (*Client) Raw

func (c *Client) Raw(ctx context.Context, method, path string, body any) ([]byte, error)

Raw retains JSON member order for Python-compatible key/value output.

func (*Client) RawContent

func (c *Client) RawContent(ctx context.Context, method, path string, content []byte, contentType string) ([]byte, error)

RawContent uses the same authenticated, bounded transport for non-JSON bodies.

func (*Client) RemovePaymentMethod

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

func (*Client) ReorderFirewallRules

func (c *Client) ReorderFirewallRules(ctx context.Context, path string, ids []string) error

func (*Client) Repositories

func (c *Client) Repositories(ctx context.Context, org string, query url.Values) (Page, error)

func (*Client) Repository

func (c *Client) Repository(ctx context.Context, org, id string) (map[string]any, error)

func (*Client) RepositoryWorkflows

func (c *Client) RepositoryWorkflows(ctx context.Context, org, repo string, query url.Values) (Page, error)

func (*Client) Request

func (c *Client) Request(ctx context.Context, method, path string, body any, headers http.Header) (map[string]any, error)

Request supports session-cookie requests during login. It does not inherit the API key: callers explicitly select the authentication for each request.

func (*Client) Rerun

func (c *Client) Rerun(ctx context.Context, org, id string, failed bool) error

func (*Client) ResolveRepository

func (c *Client) ResolveRepository(ctx context.Context, org string, query url.Values) (map[string]any, error)

func (*Client) ResolvedFirewall

func (c *Client) ResolvedFirewall(ctx context.Context, path string) (map[string]any, error)

func (*Client) RunByReference

func (c *Client) RunByReference(ctx context.Context, org, id string, platform bool, query url.Values) (map[string]any, error)

RunByReference accepts an already parsed Avrea ID or decimal platform ID. It never follows the URL supplied by a user or sends credentials to it.

func (*Client) RunJobs

func (c *Client) RunJobs(ctx context.Context, org, id string, query url.Values) (map[string]any, error)

func (*Client) RunMetrics

func (c *Client) RunMetrics(ctx context.Context, org, id string, query url.Values) (map[string]any, error)

func (*Client) Runs

func (c *Client) Runs(ctx context.Context, org string, query url.Values) (Page, error)

func (*Client) SAML

func (c *Client) SAML(ctx context.Context, path string) (map[string]any, error)

func (*Client) SBOM

func (c *Client) SBOM(ctx context.Context, path string) (map[string]any, error)

func (*Client) SBOMTaskState

func (c *Client) SBOMTaskState(ctx context.Context, path string) (map[string]any, error)

func (*Client) SBOMs

func (c *Client) SBOMs(ctx context.Context, path string, query url.Values) (Page, error)

func (*Client) SSHForwarding

func (c *Client) SSHForwarding(ctx context.Context, id string) (map[string]any, error)

func (*Client) SearchLogs

func (c *Client) SearchLogs(ctx context.Context, payload map[string]any) (map[string]any, error)

SearchLogs retains raw values for display while validating the wire record.

func (*Client) ServiceTokenIdentity added in v0.9.0

func (c *Client) ServiceTokenIdentity(ctx context.Context) (map[string]any, error)

ServiceTokenIdentity reads the presented service token's own identity. The API answers only a service token; other credentials receive 403.

func (*Client) SetDefaultPaymentMethod

func (c *Client) SetDefaultPaymentMethod(ctx context.Context, path string) (map[string]any, error)

func (*Client) SetEmailDomains

func (c *Client) SetEmailDomains(ctx context.Context, path string, domains []string) (Page, error)

func (*Client) SetSetting

func (c *Client) SetSetting(ctx context.Context, path, key string, value any) (map[string]any, error)

func (*Client) Settings

func (c *Client) Settings(ctx context.Context, path string, query url.Values) (Page, error)

func (*Client) SettingsSchema

func (c *Client) SettingsSchema(ctx context.Context, query url.Values) (Page, error)

func (*Client) SubmitAvreaCIRerun added in v0.10.0

func (c *Client) SubmitAvreaCIRerun(ctx context.Context, path string, body map[string]any) (map[string]any, error)

SubmitAvreaCIRerun carries its durable key in the request body, as the API requires.

func (*Client) SubmitFeedback added in v0.8.0

func (c *Client) SubmitFeedback(ctx context.Context, body any, key string) (map[string]any, error)

func (*Client) TransitionVM

func (c *Client) TransitionVM(ctx context.Context, path string, body any) (map[string]any, error)

func (*Client) UpdateBillingSettings

func (c *Client) UpdateBillingSettings(ctx context.Context, path string, body map[string]any) (map[string]any, error)

func (*Client) UpdateFirewallRule

func (c *Client) UpdateFirewallRule(ctx context.Context, path string, body map[string]any) (map[string]any, error)

func (*Client) UpdateVM

func (c *Client) UpdateVM(ctx context.Context, path string, request map[string]any, rules *[]any) (map[string]any, error)

func (*Client) VM

func (c *Client) VM(ctx context.Context, path string) (map[string]any, error)

func (*Client) VMCapabilities

func (c *Client) VMCapabilities(ctx context.Context, path string) (map[string]any, error)

func (*Client) VMMetrics

func (c *Client) VMMetrics(ctx context.Context, path string, query url.Values) (map[string]any, error)

func (*Client) VMUsage

func (c *Client) VMUsage(ctx context.Context, path string, query url.Values) (map[string]any, error)

func (*Client) VMs

func (c *Client) VMs(ctx context.Context, path string, query url.Values) (Page, error)

func (*Client) WorkflowAdmission added in v0.10.0

func (c *Client) WorkflowAdmission(ctx context.Context, org, repo, admission string) (map[string]any, error)

WorkflowAdmission reads the receipt of an Avrea CI dispatch.

func (*Client) WorkflowAggregates

func (c *Client) WorkflowAggregates(ctx context.Context, org string, query url.Values) (Page, error)

type ConfigurationValue added in v0.9.0

type ConfigurationValue struct {
	SecretID    string        `json:"secret_id,omitempty"`
	VariableID  string        `json:"variable_id,omitempty"`
	Name        string        `json:"name"`
	Description *string       `json:"description"`
	AsFile      bool          `json:"as_file"`
	UpdatedAt   *string       `json:"updated_at"`
	Variants    []ScopedValue `json:"variants"`
}

func (ConfigurationValue) ID added in v0.9.0

func (v ConfigurationValue) ID() string

type DownloadError

type DownloadError struct{}

DownloadError deliberately excludes URLs, credentials and transport internals.

func (*DownloadError) Error

func (*DownloadError) Error() string

type FirewallImportPreview added in v0.8.0

type FirewallImportPreview struct {
	Policy   FirewallPolicy `json:"policy"`
	Before   FirewallPolicy `json:"before"`
	After    FirewallPolicy `json:"after"`
	Revision string         `json:"revision"`
	Added    int            `json:"added"`
	Removed  int            `json:"removed"`
	Skipped  int            `json:"skipped"`
}

type FirewallPolicy added in v0.8.0

type FirewallPolicy struct {
	Version int              `json:"version"`
	Rules   []map[string]any `json:"rules"`
}

FirewallPolicy is the portable, versioned document shared with the console. Raw JSON retains absent fields so the server supplies its schema defaults.

type GitLabRunnerError

type GitLabRunnerError struct{ Message string }

func (*GitLabRunnerError) Error

func (e *GitLabRunnerError) Error() string

type HTTPError

type HTTPError struct {
	Status     int
	Path       string
	Detail     string
	RetryAfter string
	// Reauthentication holds X-Reauthentication-Required: set on a 403 that
	// asks the caller to sign in again before the operation.
	Reauthentication string
	Payload          map[string]any
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

type ObservabilityStream

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

ObservabilityStream has a single reader. Idle ticks don't cancel Read: doing that would close the WebSocket and reconnect every time the stream is quiet.

func (*ObservabilityStream) Close

func (s *ObservabilityStream) Close()

func (*ObservabilityStream) Next

func (s *ObservabilityStream) Next(ctx context.Context, idle time.Duration) ([]byte, error)

Next returns nil data on an idle tick. The owner must Close even after error.

type Page

type Page struct {
	Fields     map[string]any
	Items      []map[string]any
	NextCursor string
}

Page retains the response envelope, record maps and pagination cursor. JSON output and terminal rendering share the same decoded response values.

type ReviewAnchor added in v0.9.0

type ReviewAnchor struct {
	CommitSHA string `json:"commit_sha"`
	BaseSHA   string `json:"base_sha"`
	Path      string `json:"path"`
	Side      string `json:"side"`
	StartLine int    `json:"start_line"`
	EndLine   int    `json:"end_line"`
}

ReviewAnchor is an immutable diff location: inclusive 1-based lines on one side of the comparison between BaseSHA and CommitSHA.

type ScopedValue added in v0.9.0

type ScopedValue struct {
	VariantID               string       `json:"variant_id,omitempty"`
	VariableVariantID       string       `json:"variable_variant_id,omitempty"`
	Label                   *string      `json:"label"`
	Availability            Availability `json:"availability"`
	RotationReminderDays    *int         `json:"rotation_reminder_days,omitempty"`
	Value                   *string      `json:"value,omitempty"`
	HasValue                bool         `json:"has_value"`
	CurrentVersionID        *string      `json:"current_version_id"`
	CurrentVersion          *int         `json:"current_version"`
	CurrentVersionCreatedAt *string      `json:"current_version_created_at"`
	UpdatedAt               *string      `json:"updated_at"`
}

func (ScopedValue) ID added in v0.9.0

func (v ScopedValue) ID() string

type StreamError

type StreamError struct {
	HTTPStatus int
	CloseCode  int
	Reason     string
}

StreamError retains retry decisions without leaking transport URLs or headers.

func (*StreamError) Error

func (e *StreamError) Error() string

type TimingEvent

type TimingEvent struct {
	Name         string  `json:"name"`
	Milliseconds float64 `json:"ms"`
	Attempt      int     `json:"attempt,omitempty"`
	Failed       bool    `json:"failed,omitempty"`
}

TimingEvent records an offset from the start of one HTTP operation. Events retain concurrent connection attempts rather than adding overlapping durations.

type TransportError

type TransportError struct{ Message, Reason string }

TransportError preserves retry classification without exposing net/http's original error, which can include sensitive request URLs.

func (*TransportError) Error

func (e *TransportError) Error() string

type ValueWrite added in v0.9.0

type ValueWrite struct {
	VersionID string `json:"version_id"`
	Status    string `json:"status"`
}

Jump to

Keyboard shortcuts

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