Documentation
¶
Overview ¶
Package apiclient is a thin typed client for branchd's REST API, used by the CLI in server mode (PGBRANCH_SERVER / --server).
Index ¶
- func IsNotFound(err error) bool
- type Client
- func (c *Client) BranchUsage(ctx context.Context, name string) (int64, error)
- func (c *Client) CreateBranch(ctx context.Context, req api.CreateBranchRequest) (*api.Branch, error)
- func (c *Client) CreateSource(ctx context.Context, req api.CreateSourceRequest) (*api.Source, error)
- func (c *Client) DestroyBranch(ctx context.Context, name string) error
- func (c *Client) DiffBranch(ctx context.Context, name string) (*engine.DiffResult, error)
- func (c *Client) GetBranch(ctx context.Context, name string) (*api.Branch, error)
- func (c *Client) GetMaskScripts(ctx context.Context, name string) ([]api.MaskScript, error)
- func (c *Client) ListBranches(ctx context.Context) ([]api.Branch, error)
- func (c *Client) ListSources(ctx context.Context) ([]api.Source, error)
- func (c *Client) RefreshSource(ctx context.Context, name, password string) (*api.Source, error)
- func (c *Client) RemoveSource(ctx context.Context, name string) error
- func (c *Client) ResetBranch(ctx context.Context, name string) (*api.Branch, error)
- func (c *Client) SetMaskScripts(ctx context.Context, name string, scripts []api.MaskScript) ([]api.MaskScript, error)
- type StatusError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNotFound ¶
IsNotFound reports whether err is a server response with status 404.
Types ¶
type Client ¶
type Client struct {
BaseURL string // e.g. http://localhost:7070 or https://branchd.example:7070
Token string // bearer token (PGBRANCH_TOKEN)
HTTP *http.Client
}
func New ¶
New builds a client for the given base URL (http or https). For branchd instances serving a self-signed certificate, PGBRANCH_TLS_SKIP_VERIFY=1 disables certificate verification (read once, here).
func (*Client) BranchUsage ¶
BranchUsage returns the branch's rw-layer disk usage in bytes. The server runs a helper container per call — treat it as an on-demand probe.
func (*Client) CreateBranch ¶
func (*Client) CreateSource ¶
func (*Client) DestroyBranch ¶
func (*Client) DiffBranch ¶ added in v0.3.0
DiffBranch returns what changed in a branch relative to its base (unified schema diff + per-table row-estimate deltas). The server provisions a throwaway clone of the branch's base and pg_dumps both instances per call — expect ~5-10s.
func (*Client) GetMaskScripts ¶
func (*Client) ListBranches ¶
func (*Client) ListSources ¶
func (*Client) RefreshSource ¶
func (*Client) ResetBranch ¶
func (*Client) SetMaskScripts ¶
func (c *Client) SetMaskScripts(ctx context.Context, name string, scripts []api.MaskScript) ([]api.MaskScript, error)
SetMaskScripts replaces a source's masking scripts (empty slice clears them) and returns the stored list.
type StatusError ¶
StatusError is returned for non-2xx responses; it carries the HTTP status so callers can branch on it (e.g. tolerate 404s).
func (*StatusError) Error ¶
func (e *StatusError) Error() string