Documentation
¶
Overview ¶
Package platform contains the hosted WhoDB client used by CLI commands.
Index ¶
- Constants
- func IsInvalidGrant(err error) bool
- func Logout(ctx context.Context, host, accessToken string) error
- func NormalizeHost(raw string) (string, error)
- func ResolveAuthHost(ctx context.Context, host string) (string, error)
- type AuthConfig
- type AuthHTTPError
- type Client
- func (c *Client) CreateSource(ctx context.Context, input CreateSourceInput) (*Source, error)
- func (c *Client) DeleteSource(ctx context.Context, projectID, sourceID string) error
- func (c *Client) Host() string
- func (c *Client) Me(ctx context.Context) (*User, error)
- func (c *Client) Organizations(ctx context.Context) ([]Organization, error)
- func (c *Client) ProjectSources(ctx context.Context, projectID string) ([]Source, error)
- func (c *Client) Projects(ctx context.Context, orgID string) ([]Project, error)
- func (c *Client) SourceColumns(ctx context.Context, projectID, sourceID string, ref SourceObjectRefInput) ([]Column, error)
- func (c *Client) SourceObjects(ctx context.Context, projectID, sourceID string, parent *SourceObjectRefInput, ...) ([]SourceObject, error)
- func (c *Client) SourceRows(ctx context.Context, projectID, sourceID string, ref SourceObjectRefInput, ...) (*RowsResult, error)
- func (c *Client) SourceTypes(ctx context.Context) ([]SourceType, error)
- func (c *Client) SwitchOrganization(ctx context.Context, orgID string) (*Organization, error)
- type Column
- type CreateSourceInput
- type LoginOptions
- type Organization
- type Project
- type Record
- type RowsResult
- type Source
- type SourceConnectionField
- type SourceObject
- type SourceObjectKind
- type SourceObjectRef
- type SourceObjectRefInput
- type SourceType
- type TokenResponse
- type User
Constants ¶
const (
// DefaultHost is the hosted WhoDB platform URL used when no host is provided.
DefaultHost = "https://app.whodb.com"
)
Variables ¶
This section is empty.
Functions ¶
func IsInvalidGrant ¶
IsInvalidGrant reports whether an auth failure means the refresh token is no longer usable.
func NormalizeHost ¶
NormalizeHost canonicalizes hosted WhoDB URLs for config and requests.
Types ¶
type AuthConfig ¶
type AuthConfig struct {
MothergateURL string `json:"mothergateUrl"`
}
AuthConfig is the public auth configuration advertised by a WhoDB platform host.
type AuthHTTPError ¶
AuthHTTPError describes a failed Mothergate auth endpoint response.
func (*AuthHTTPError) Error ¶
func (e *AuthHTTPError) Error() string
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client sends authenticated requests to a hosted WhoDB platform endpoint.
func (*Client) CreateSource ¶
CreateSource creates a hosted source in one project.
func (*Client) DeleteSource ¶
DeleteSource deletes a hosted source from one project.
func (*Client) Organizations ¶
func (c *Client) Organizations(ctx context.Context) ([]Organization, error)
Organizations returns organizations visible to the authenticated user.
func (*Client) ProjectSources ¶
ProjectSources returns sources visible to the user in one project.
func (*Client) SourceColumns ¶
func (c *Client) SourceColumns(ctx context.Context, projectID, sourceID string, ref SourceObjectRefInput) ([]Column, error)
SourceColumns returns columns for one hosted source object.
func (*Client) SourceObjects ¶
func (c *Client) SourceObjects(ctx context.Context, projectID, sourceID string, parent *SourceObjectRefInput, kinds []SourceObjectKind, pageSize, pageOffset int) ([]SourceObject, error)
SourceObjects returns browseable objects for one hosted source.
func (*Client) SourceRows ¶
func (c *Client) SourceRows(ctx context.Context, projectID, sourceID string, ref SourceObjectRefInput, pageSize, pageOffset int) (*RowsResult, error)
SourceRows returns rows for one hosted source object.
func (*Client) SourceTypes ¶
func (c *Client) SourceTypes(ctx context.Context) ([]SourceType, error)
SourceTypes returns source types available on the hosted platform.
func (*Client) SwitchOrganization ¶
SwitchOrganization updates the user's active organization on the hosted platform.
type Column ¶
type Column struct {
Type string `json:"type"`
Name string `json:"name"`
MetadataFidelity string `json:"metadataFidelity"`
IsPrimary bool `json:"isPrimary"`
IsForeignKey bool `json:"isForeignKey"`
ReferencedTable string `json:"referencedTable,omitempty"`
ReferencedColumn string `json:"referencedColumn,omitempty"`
Length *int `json:"length,omitempty"`
Precision *int `json:"precision,omitempty"`
Scale *int `json:"scale,omitempty"`
}
Column describes a column returned by a hosted source.
type CreateSourceInput ¶
type CreateSourceInput struct {
ProjectID string
Name string
DatabaseType string
Hostname string
Port string
Username string
Password string
Database string
Advanced map[string]string
}
CreateSourceInput describes a hosted WhoDB source to create in one project.
type LoginOptions ¶
type LoginOptions struct {
Host string
OpenBrowser bool
PrintURL func(string)
Timeout time.Duration
}
LoginOptions configures the browser PKCE login flow.
type Organization ¶
type Organization struct {
ID string `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
}
Organization is a WhoDB platform organization visible to the user.
type Project ¶
type Project struct {
ID string `json:"id"`
OrgID string `json:"orgId"`
Name string `json:"name"`
Slug string `json:"slug"`
Description string `json:"description"`
}
Project is a WhoDB platform project visible to the user.
type RowsResult ¶
type RowsResult struct {
Columns []Column `json:"columns"`
Rows [][]string `json:"rows"`
DisableUpdate bool `json:"disableUpdate"`
TotalCount int `json:"totalCount"`
}
RowsResult contains tabular rows returned by a hosted source.
type Source ¶
type Source struct {
ID string `json:"id"`
ProjectID string `json:"projectId"`
Name string `json:"name"`
DatabaseType string `json:"databaseType"`
CreatedBy string `json:"createdBy"`
CreatedAt string `json:"createdAt"`
}
Source is a hosted WhoDB project source visible to the authenticated user.
type SourceConnectionField ¶
type SourceConnectionField struct {
Key string `json:"key"`
Kind string `json:"kind"`
Section string `json:"section"`
Required bool `json:"required"`
LabelKey string `json:"labelKey"`
PlaceholderKey *string `json:"placeholderKey,omitempty"`
DefaultValue *string `json:"defaultValue,omitempty"`
SupportsOptions bool `json:"supportsOptions"`
}
SourceConnectionField describes one source credential/configuration field.
type SourceObject ¶
type SourceObject struct {
Ref SourceObjectRef `json:"ref"`
Kind SourceObjectKind `json:"kind"`
Name string `json:"name"`
Path []string `json:"path"`
HasChildren bool `json:"hasChildren"`
Actions []string `json:"actions"`
Metadata []Record `json:"metadata"`
}
SourceObject is a browsable object returned by a hosted source.
type SourceObjectKind ¶
type SourceObjectKind string
SourceObjectKind identifies a source hierarchy object kind.
type SourceObjectRef ¶
type SourceObjectRef struct {
Kind SourceObjectKind `json:"kind"`
Locator string `json:"locator"`
Path []string `json:"path"`
}
SourceObjectRef identifies one object inside a source hierarchy.
type SourceObjectRefInput ¶
type SourceObjectRefInput struct {
Kind SourceObjectKind
Locator string
Path []string
}
SourceObjectRefInput identifies one source object in GraphQL variables.
type SourceType ¶
type SourceType struct {
ID string `json:"id"`
Label string `json:"label"`
Connector string `json:"connector"`
Category string `json:"category"`
ConnectionFields []SourceConnectionField `json:"connectionFields"`
}
SourceType describes one hosted WhoDB source type available for creation.
type TokenResponse ¶
type TokenResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token,omitempty"`
IDToken string `json:"id_token,omitempty"`
ExpiresIn int `json:"expires_in,omitempty"`
}
TokenResponse is returned by Mothergate auth exchange and refresh endpoints.
func ExchangeCode ¶
func ExchangeCode(ctx context.Context, authHost, code, redirectURI, verifier string) (*TokenResponse, error)
ExchangeCode exchanges a PKCE authorization code for platform tokens.
func Login ¶
func Login(ctx context.Context, opts LoginOptions) (*TokenResponse, error)
Login runs the browser-based PKCE flow and returns platform tokens.
func RefreshToken ¶
func RefreshToken(ctx context.Context, host, refreshToken string) (*TokenResponse, error)
RefreshToken exchanges a refresh token for new platform tokens.