api

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateAPIKeyRequest

type CreateAPIKeyRequest struct {
	Name      string     `json:"name"`
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
}

CreateAPIKeyRequest creates an admin API key for fallbck-ctl / automation

type CreateAPIKeyResponse

type CreateAPIKeyResponse struct {
	ID        uuid.UUID  `json:"id"`
	Name      string     `json:"name"`
	RawKey    string     `json:"raw_key"`
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
}

CreateAPIKeyResponse returns the raw key exactly once

type CreateTokenRequest

type CreateTokenRequest struct {
	Name      string    `json:"name"`
	MaxUses   int       `json:"max_uses"` // 0 for unlimited, default 1
	ExpiresAt time.Time `json:"expires_at"`
}

CreateTokenRequest is used by the admin UI/CLI to create an agent enrollment token

type CreateTokenResponse

type CreateTokenResponse struct {
	ID        uuid.UUID `json:"id"`
	Name      string    `json:"name"`
	RawToken  string    `json:"raw_token"`
	ExpiresAt time.Time `json:"expires_at"`
	MaxUses   int       `json:"max_uses"`
}

CreateTokenResponse returns the raw one-time enrollment token to the admin

type EnrollRequest

type EnrollRequest struct {
	Token     string `json:"token"`
	Hostname  string `json:"hostname"`
	OS        string `json:"os"`
	Arch      string `json:"arch"`
	Version   string `json:"version"`
	IPAddress string `json:"ip_address,omitempty"`
}

EnrollRequest is sent by an agent to enroll with the central server

type EnrollResponse

type EnrollResponse struct {
	AgentID        uuid.UUID `json:"agent_id"`
	TaskQueue      string    `json:"task_queue"`
	Namespace      string    `json:"namespace"`
	AuthToken      string    `json:"auth_token"`
	TokenExpiresAt time.Time `json:"token_expires_at"`
	ServerURL      string    `json:"server_url"`
	// ServerCAPEM optionally carries a private CA bundle the agent must trust for ServerURL
	ServerCAPEM string `json:"server_ca_pem,omitempty"`
	ProxyURL    string `json:"proxy_url"`
}

EnrollResponse contains the credentials and configuration needed for the agent to start. Everything the agent talks to (HTTP API, PBS proxy, Temporal gRPC) lives behind ServerURL.

type HeartbeatRequest

type HeartbeatRequest struct {
	AgentID uuid.UUID `json:"agent_id"`
	Status  string    `json:"status"`
	Version string    `json:"version"`
}

HeartbeatRequest is sent by an agent periodically

type MeResponse

type MeResponse struct {
	Kind    string `json:"kind"`
	Subject string `json:"subject"`
	Email   string `json:"email,omitempty"`
	Name    string `json:"name,omitempty"`
}

MeResponse describes the authenticated admin principal

type Middleware

type Middleware = func(http.Handler) http.Handler

Middleware is a chi-compatible middleware

type RotateTokenResponse

type RotateTokenResponse struct {
	AuthToken      string    `json:"auth_token"`
	TokenExpiresAt time.Time `json:"token_expires_at"`
}

RotateTokenResponse carries a freshly issued agent token

type ServerAPI

type ServerAPI struct {
	DB           *db.DB
	Temporal     client.Client
	Config       *config.ServerConfig
	TokenManager *auth.TokenManager
	// Verifier is used to invalidate cached agent state on revocation (may be nil)
	Verifier *auth.AgentVerifier
}

ServerAPI holds database, Temporal client, config and token services for HTTP requests

func NewServerAPI

func NewServerAPI(database *db.DB, temporalClient client.Client, cfg *config.ServerConfig, tm *auth.TokenManager, verifier *auth.AgentVerifier) *ServerAPI

NewServerAPI initializes the API service

func (*ServerAPI) HandleAgentEnroll

func (s *ServerAPI) HandleAgentEnroll(w http.ResponseWriter, r *http.Request)

HandleAgentEnroll processes an agent enrollment request with a one-time token and issues the agent its bearer token.

func (*ServerAPI) HandleAgentHeartbeat

func (s *ServerAPI) HandleAgentHeartbeat(w http.ResponseWriter, r *http.Request)

HandleAgentHeartbeat updates agent last_seen_at and status

func (*ServerAPI) HandleCreateAPIKey

func (s *ServerAPI) HandleCreateAPIKey(w http.ResponseWriter, r *http.Request)

HandleCreateAPIKey mints an admin API key

func (*ServerAPI) HandleCreateJob

func (s *ServerAPI) HandleCreateJob(w http.ResponseWriter, r *http.Request)

HandleCreateJob creates a backup job

func (*ServerAPI) HandleCreateTarget

func (s *ServerAPI) HandleCreateTarget(w http.ResponseWriter, r *http.Request)

HandleCreateTarget registers a new backup target

func (*ServerAPI) HandleCreateToken

func (s *ServerAPI) HandleCreateToken(w http.ResponseWriter, r *http.Request)

HandleCreateToken creates a new one-time enrollment token

func (*ServerAPI) HandleDeleteAgent

func (s *ServerAPI) HandleDeleteAgent(w http.ResponseWriter, r *http.Request)

HandleDeleteAgent removes an agent

func (*ServerAPI) HandleDeleteJob

func (s *ServerAPI) HandleDeleteJob(w http.ResponseWriter, r *http.Request)

HandleDeleteJob deletes a job

func (*ServerAPI) HandleDeleteTarget

func (s *ServerAPI) HandleDeleteTarget(w http.ResponseWriter, r *http.Request)

HandleDeleteTarget deletes a target

func (*ServerAPI) HandleGetAgent

func (s *ServerAPI) HandleGetAgent(w http.ResponseWriter, r *http.Request)

HandleGetAgent returns a single agent by ID

func (*ServerAPI) HandleGetJob

func (s *ServerAPI) HandleGetJob(w http.ResponseWriter, r *http.Request)

HandleGetJob returns job by ID

func (*ServerAPI) HandleGetTarget

func (s *ServerAPI) HandleGetTarget(w http.ResponseWriter, r *http.Request)

HandleGetTarget gets target by ID

func (*ServerAPI) HandleHealth

func (s *ServerAPI) HandleHealth(w http.ResponseWriter, r *http.Request)

HandleHealth returns the system health status

func (*ServerAPI) HandleListAPIKeys

func (s *ServerAPI) HandleListAPIKeys(w http.ResponseWriter, r *http.Request)

HandleListAPIKeys lists API keys (hashes are never returned)

func (*ServerAPI) HandleListAgents

func (s *ServerAPI) HandleListAgents(w http.ResponseWriter, r *http.Request)

HandleListAgents returns all registered agents

func (*ServerAPI) HandleListJobs

func (s *ServerAPI) HandleListJobs(w http.ResponseWriter, r *http.Request)

HandleListJobs returns all jobs

func (*ServerAPI) HandleListRuns

func (s *ServerAPI) HandleListRuns(w http.ResponseWriter, r *http.Request)

HandleListRuns returns recent backup runs

func (*ServerAPI) HandleListTargets

func (s *ServerAPI) HandleListTargets(w http.ResponseWriter, r *http.Request)

HandleListTargets returns all backup targets

func (*ServerAPI) HandleListTokens

func (s *ServerAPI) HandleListTokens(w http.ResponseWriter, r *http.Request)

HandleListTokens lists all enrollment tokens

func (*ServerAPI) HandleMe

func (s *ServerAPI) HandleMe(w http.ResponseWriter, r *http.Request)

HandleMe returns the authenticated admin principal

func (*ServerAPI) HandleRevokeAPIKey

func (s *ServerAPI) HandleRevokeAPIKey(w http.ResponseWriter, r *http.Request)

HandleRevokeAPIKey revokes an API key

func (*ServerAPI) HandleRotateAgentToken

func (s *ServerAPI) HandleRotateAgentToken(w http.ResponseWriter, r *http.Request)

HandleRotateAgentToken issues a fresh bearer token to an authenticated agent (same token version, so the old token stays valid until it expires or the agent is revoked).

func (*ServerAPI) HandleTriggerJob

func (s *ServerAPI) HandleTriggerJob(w http.ResponseWriter, r *http.Request)

HandleTriggerJob starts an on-demand backup execution for a job

func (*ServerAPI) RegisterRoutes

func (s *ServerAPI) RegisterRoutes(r chi.Router, admin, agent Middleware)

RegisterRoutes registers all API routes onto the Chi router. admin protects the administrative API, agent protects agent-authenticated endpoints.

Jump to

Keyboard shortcuts

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