Documentation
¶
Index ¶
- type APICallRequest
- type APICallResponse
- type APIError
- type AuthFile
- type Client
- func (c *Client) APICall(ctx context.Context, request APICallRequest) (APICallResponse, error)
- func (c *Client) ListAuthFiles(ctx context.Context) ([]AuthFile, error)
- func (c *Client) Raw(ctx context.Context, method, relativePath string, body []byte) (RawResponse, error)
- func (c *Client) RawRequest(ctx context.Context, method, relativePath string, body []byte) ([]byte, error)
- func (c *Client) SetAuthFileDisabled(ctx context.Context, name, authIndex string, disabled bool) error
- func (c *Client) ValidateRelativePath(relativePath string) error
- type RawResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APICallRequest ¶
type APICallRequest struct {
AuthIndex string `json:"auth_index,omitempty"`
Method string `json:"method"`
URL string `json:"url"`
Header map[string]string `json:"header,omitempty"`
Data string `json:"data,omitempty"`
}
APICallRequest is the request body accepted by POST /api-call.
type APICallResponse ¶
type APICallResponse struct {
StatusCode int `json:"status_code"`
Header http.Header `json:"header"`
Body []byte `json:"body"`
}
APICallResponse preserves the upstream status independently of the Management API HTTP status. Body contains decoded string bytes or raw nested JSON bytes, depending on the upstream response shape.
type APIError ¶
type APIError struct {
StatusCode int `json:"status_code"`
Code string `json:"code"`
Message string `json:"message"`
}
APIError classifies a non-successful Management API response.
type AuthFile ¶
type AuthFile struct {
ID string `json:"id"`
AuthIndex string `json:"auth_index"`
Name string `json:"name"`
Provider string `json:"provider"`
Type string `json:"type"`
Account string `json:"account"`
Email string `json:"email"`
Status string `json:"status"`
StatusMessage string `json:"status_message"`
Disabled bool `json:"disabled"`
RuntimeOnly bool `json:"runtime_only"`
UpdatedAt string `json:"updated_at"`
// Presence flags distinguish the auth-dir fallback response from an
// explicit runtime state. A JSON null is not a known boolean state.
DisabledPresent bool `json:"-"`
RuntimeOnlyPresent bool `json:"-"`
Raw map[string]json.RawMessage `json:"-"`
}
AuthFile is the stable subset of GET /auth-files used by the CLI. Raw keeps upstream fields that are not yet modelled, including the distinction between an absent fallback field and its Go zero value.
func (*AuthFile) UnmarshalJSON ¶
UnmarshalJSON retains fields not represented by AuthFile without deriving values for fields omitted by the auth-dir fallback response.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls one CLIProxyAPI Management API origin.
func New ¶
New creates a client for a full Management API base URL, normally ending in /v0/management. Redirects are disabled on a copy of the supplied client so the bearer credential cannot cross origins.
func (*Client) APICall ¶
func (c *Client) APICall(ctx context.Context, request APICallRequest) (APICallResponse, error)
APICall asks CLIProxyAPI to make an authenticated upstream request. A non-2xx StatusCode belongs to that upstream response and is returned normally when the Management API itself answered successfully.
func (*Client) ListAuthFiles ¶
ListAuthFiles returns auth files in exactly the order supplied by the Management API.
func (*Client) Raw ¶
func (c *Client) Raw(ctx context.Context, method, relativePath string, body []byte) (RawResponse, error)
Raw calls a path below the configured Management API base and preserves the successful Management HTTP status, headers, and body.
func (*Client) RawRequest ¶
func (c *Client) RawRequest(ctx context.Context, method, relativePath string, body []byte) ([]byte, error)
RawRequest calls a path below the configured Management API base. It rejects URLs and traversal before constructing the request target.
func (*Client) SetAuthFileDisabled ¶
func (c *Client) SetAuthFileDisabled(ctx context.Context, name, authIndex string, disabled bool) error
SetAuthFileDisabled changes one auth record. It performs one PATCH attempt; retry policy belongs to the caller and must account for ambiguous writes.
func (*Client) ValidateRelativePath ¶ added in v1.0.3
ValidateRelativePath reports whether a raw request path resolves below the configured Management API base, using the same rules the execute path applies. Callers use it to reject a bad path while previewing, so a dry-run never hands back a confirm token for a request that cannot run.