Documentation
¶
Overview ¶
Package cloud provides a small, dependency-free client for OpenVaultDB Cloud registration metadata. It does not access database records or credentials.
Index ¶
- Constants
- Variables
- type APIError
- type Client
- func (c *Client) CreateDemoSession(ctx context.Context, accessToken string, request CreateDemoSessionRequest) (DemoSession, error)
- func (c *Client) EndDemoSession(ctx context.Context, accessToken, sessionID string) error
- func (c *Client) GetDatabase(ctx context.Context, accessToken, id string) (GetDatabaseResponse, error)
- func (c *Client) GetDemoSession(ctx context.Context, accessToken, spaceID string) (DemoSessionMetadata, error)
- func (c *Client) ListDatabases(ctx context.Context, accessToken string, request ListDatabasesRequest) (ListDatabasesResponse, error)
- type CreateDemoSessionRequest
- type Database
- type DemoSession
- type DemoSessionMetadata
- type GetDatabaseResponse
- type ListDatabasesRequest
- type ListDatabasesResponse
- type Option
Constants ¶
const ( // DefaultPageSize is the number of registrations requested when a list // request does not specify a page size. DefaultPageSize = 100 // MaxPageSize is the largest page accepted by the cloud catalogue API. MaxPageSize = 100 )
Variables ¶
var ( // ErrMissingAccessToken is returned before making an unauthenticated API // request. ErrMissingAccessToken = errors.New("cloud access token is required") // ErrResponseTooLarge prevents an API response from consuming unbounded // memory in a client process. ErrResponseTooLarge = errors.New("cloud API response exceeds size limit") )
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError is a structured error returned by the cloud catalogue API. Description is API-provided text. Callers that display it in a terminal or another rendered surface must sanitize it. Arbitrary response bodies are never included in Error.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client makes authenticated, read-only requests to the public OpenVaultDB Cloud catalogue API.
func NewClient ¶
NewClient creates a catalogue client for an absolute http(s) base URL. HTTP is accepted only for loopback development, so bearer tokens are never sent to a remote cleartext host.
func (*Client) CreateDemoSession ¶ added in v0.3.0
func (c *Client) CreateDemoSession(ctx context.Context, accessToken string, request CreateDemoSessionRequest) (DemoSession, error)
CreateDemoSession creates one bounded Listus demo session. The access token must carry the demo:write device scope.
func (*Client) EndDemoSession ¶ added in v0.3.0
EndDemoSession asks Cloud to end the caller's active session. It is safe to call again after a successful end.
func (*Client) GetDatabase ¶
func (c *Client) GetDatabase(ctx context.Context, accessToken, id string) (GetDatabaseResponse, error)
GetDatabase returns one accessible registration by its opaque ID.
func (*Client) GetDemoSession ¶ added in v0.3.0
func (c *Client) GetDemoSession(ctx context.Context, accessToken, spaceID string) (DemoSessionMetadata, error)
GetDemoSession returns safe metadata for the caller's active session in a Space. No origin or connector credentials are returned.
func (*Client) ListDatabases ¶
func (c *Client) ListDatabases(ctx context.Context, accessToken string, request ListDatabasesRequest) (ListDatabasesResponse, error)
ListDatabases returns one page of accessible registrations.
type CreateDemoSessionRequest ¶ added in v0.3.0
type CreateDemoSessionRequest struct {
RequestID string `json:"requestId"`
App string `json:"app"`
LocalPort int `json:"localPort"`
OriginToken string `json:"originToken"`
}
CreateDemoSessionRequest asks OpenVaultDB Cloud to bind a local, loopback Listus database to the caller's dedicated demo Space. OriginToken is a database-scoped secret: callers must never log or persist it.
type Database ¶
type Database struct {
ID string `json:"id"`
Name string `json:"name"`
SpaceID string `json:"spaceId"`
SpaceType string `json:"spaceType"`
Provider string `json:"provider"`
Status string `json:"status"`
SpaceName string `json:"spaceName,omitempty"`
ServerURL string `json:"serverUrl,omitempty"`
ServerDatabaseID string `json:"serverDatabaseId,omitempty"`
Repository string `json:"repository,omitempty"`
Branch string `json:"branch,omitempty"`
Path string `json:"path,omitempty"`
CreatedAt *time.Time `json:"createdAt,omitempty"`
UpdatedAt *time.Time `json:"updatedAt,omitempty"`
}
Database is safe registration metadata for one database in an accessible Space. It deliberately excludes database records and provider credentials.
type DemoSession ¶ added in v0.3.0
type DemoSession struct {
SessionID string `json:"sessionId"`
OwnerUserID string `json:"ownerUserId"`
SpaceID string `json:"spaceId"`
SpaceType string `json:"spaceType"`
DatabaseID string `json:"databaseId"`
ExpiresAt time.Time `json:"expiresAt"`
ProxyURL string `json:"proxyUrl"`
AppURL string `json:"appUrl"`
TunnelToken string `json:"tunnelToken,omitempty"`
}
DemoSession is the response to creating a demo session. TunnelToken is response-body-only and must be delivered to cloudflared via a protected temporary file, never rendered in a URL or log.
type DemoSessionMetadata ¶ added in v0.3.0
type DemoSessionMetadata struct {
SessionID string `json:"sessionId"`
OwnerUserID string `json:"ownerUserId"`
SpaceID string `json:"spaceId"`
SpaceType string `json:"spaceType"`
DatabaseID string `json:"databaseId"`
ExpiresAt time.Time `json:"expiresAt"`
ProxyURL string `json:"proxyUrl"`
AppURL string `json:"appUrl"`
}
DemoSessionMetadata is the safe response returned to a signed-in owner. It deliberately excludes tunnel and origin credentials.
type GetDatabaseResponse ¶
type GetDatabaseResponse struct {
Database Database `json:"database"`
}
GetDatabaseResponse is the envelope returned for a single registration.
type ListDatabasesRequest ¶
ListDatabasesRequest limits a catalogue list to one Space when Space is "personal" or an opaque Space ID. PageToken is opaque and must be passed unchanged from a previous response.
type ListDatabasesResponse ¶
type ListDatabasesResponse struct {
Databases []Database `json:"databases"`
NextPageToken string `json:"nextPageToken,omitempty"`
}
ListDatabasesResponse is one page of database registration metadata. Databases is always non-nil, including for an empty response.
type Option ¶
type Option func(*clientConfig) error
Option configures a Client.
func WithHTTPClient ¶
WithHTTPClient uses a copy of client for requests. Redirect following is always disabled so bearer credentials are never forwarded to another host.
func WithMaxResponseBytes ¶
WithMaxResponseBytes sets an upper bound for both success and error bodies.