apiclient

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

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

func New(baseURL, token string) *Client

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

func (c *Client) BranchUsage(ctx context.Context, name string) (int64, error)

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 (c *Client) CreateBranch(ctx context.Context, req api.CreateBranchRequest) (*api.Branch, error)

func (*Client) CreateSource

func (c *Client) CreateSource(ctx context.Context, req api.CreateSourceRequest) (*api.Source, error)

func (*Client) DestroyBranch

func (c *Client) DestroyBranch(ctx context.Context, name string) error

func (*Client) DiffBranch added in v0.3.0

func (c *Client) DiffBranch(ctx context.Context, name string) (*engine.DiffResult, error)

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) GetBranch

func (c *Client) GetBranch(ctx context.Context, name string) (*api.Branch, error)

func (*Client) GetMaskScripts

func (c *Client) GetMaskScripts(ctx context.Context, name string) ([]api.MaskScript, error)

func (*Client) ListBranches

func (c *Client) ListBranches(ctx context.Context) ([]api.Branch, error)

func (*Client) ListSources

func (c *Client) ListSources(ctx context.Context) ([]api.Source, error)

func (*Client) RefreshSource

func (c *Client) RefreshSource(ctx context.Context, name, password string) (*api.Source, error)

func (*Client) RemoveSource

func (c *Client) RemoveSource(ctx context.Context, name string) error

func (*Client) ResetBranch

func (c *Client) ResetBranch(ctx context.Context, name string) (*api.Branch, error)

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

type StatusError struct {
	StatusCode int
	Message    string
}

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

Jump to

Keyboard shortcuts

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