api

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package api is branchd's REST control plane: a thin JSON layer over the engine. stdlib net/http only; routes use Go 1.22 method patterns. All /v1 routes require the bearer token; /healthz does not.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Branch

type Branch struct {
	Name   string `json:"name"`
	Source string `json:"source"`
	// Parent is the branch this one was created from (branch-from-branch);
	// "" when created directly from the source.
	Parent   string `json:"parent,omitempty"`
	State    string `json:"state"`
	Host     string `json:"host"`
	Port     int    `json:"port"`
	User     string `json:"user"`
	Database string `json:"database"`
	// ProxyDatabase is the database param to use when connecting through the
	// wire-protocol router: dbname@branch.
	ProxyDatabase string `json:"proxy_database"`
	ExpiresAt     string `json:"expires_at,omitempty"`
	CreatedAt     string `json:"created_at"`
}

type CreateBranchRequest

type CreateBranchRequest struct {
	Name       string `json:"name"`
	Source     string `json:"source,omitempty"`
	Parent     string `json:"parent,omitempty"`
	TTLSeconds int    `json:"ttl_seconds"`
}

CreateBranchRequest creates a branch off a source (Source) or off another branch (Parent) — exactly one of the two must be set.

type CreateSourceRequest

type CreateSourceRequest struct {
	Name      string `json:"name"`
	Host      string `json:"host"`
	Port      int    `json:"port"`
	User      string `json:"user"`
	Database  string `json:"database"`
	Network   string `json:"network"`
	PGVersion string `json:"pg_version"`
	Password  string `json:"password"`
}

type MaskScript

type MaskScript struct {
	Name string `json:"name"`
	SQL  string `json:"sql"`
}

MaskScript is one per-source masking statement, applied in order inside every new/reset branch before it is marked ready.

type RefreshSourceRequest

type RefreshSourceRequest struct {
	Password string `json:"password"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(eng *engine.Engine, reg *registry.Registry, token string) *Server

func (*Server) Handler

func (s *Server) Handler() http.Handler

type Source

type Source struct {
	Name       string `json:"name"`
	PGVersion  string `json:"pg_version"`
	Host       string `json:"host"`
	Port       int    `json:"port"`
	User       string `json:"user"`
	Database   string `json:"database"`
	Network    string `json:"network,omitempty"`
	State      string `json:"state"`
	Generation int    `json:"generation"`
	CreatedAt  string `json:"created_at"`
}

Jump to

Keyboard shortcuts

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