api

package
v0.0.0-...-681ab99 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api owns the versioned loopback management HTTP boundary. It exposes only generated transport DTOs and delegates durable authority to Backend.

Index

Constants

View Source
const (
	Prefix                  = "/api/v1"
	MaximumRequestBodyBytes = int64(16 << 20)
	DefaultAuditPageSize    = 100
	MaximumAuditPageSize    = 500
)

Variables

View Source
var (
	ErrBackendUnavailable     = errors.New("management backend is unavailable")
	ErrResourceNotFound       = errors.New("management resource was not found")
	ErrDomainConflict         = errors.New("management operation conflicts with current state")
	ErrGitHubCallbackConflict = errors.New("GitHub App callback state conflicts with current state")
)

Functions

func NewHandler

func NewHandler(options Options) (http.Handler, error)

Types

type AuditInput

type AuditInput struct {
	Actor        string
	Action       string
	Outcome      string
	ResourceType string
	ResourceID   string
	ErrorCode    string
	RequestID    string
}

AuditInput deliberately has no raw detail, body, header, or credential field.

type AuditPage

type AuditPage struct {
	Events      []gen.AuditEvent
	NextAfter   *uint64
	ResumeAfter *uint64
}

type Backend

type Backend interface {
	RecordAudit(context.Context, AuditInput) error
	AuditHealthy() bool
	Setup(context.Context) (gen.Setup, error)
	Overview(context.Context) (gen.Overview, error)
	Nodes(context.Context) ([]gen.Node, gen.Revision, error)
	Targets(context.Context) ([]gen.Target, gen.Revision, error)
	Runs(context.Context) ([]gen.Run, error)
	AuditEvents(context.Context, uint64, int) (AuditPage, error)
	ReadConfiguration(context.Context) (gen.Configuration, error)
	ApplyConfiguration(context.Context, uint64, string, []byte, string) (gen.Configuration, error)
	ExportConfiguration(context.Context) ([]byte, gen.Revision, error)
	CreateJoinCode(context.Context, []string, string) (tokenID, code string, err error)
	CancelJoinCode(context.Context, string, string) error
	SetNodeAdministrativeState(context.Context, domain.NodeID, domain.NodeAdministrativeState, uint64, string) (gen.Node, gen.Revision, error)
	CurrentRevision(context.Context) (gen.Revision, error)
}

Backend is the sole authority used by the HTTP adapter. Implementations keep database transactions, GitHub verification, and reconciliation out of handlers.

type CommittedMutationError

type CommittedMutationError struct {
	Current uint64
}

CommittedMutationError means SQLite and audit authority advanced, but the live projection or response could not be confirmed. The revision lets clients reload instead of blindly retrying an operation that may already have effect.

func (*CommittedMutationError) Error

func (committed *CommittedMutationError) Error() string

type EventBus

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

EventBus coalesces invalidations for each slow subscriber. It retains no event history; an unknown cursor is handled by a level-triggered reset.

func NewEventBus

func NewEventBus() *EventBus

func (*EventBus) Generation

func (bus *EventBus) Generation() uint64

Generation returns the current process-local invalidation high-water mark. It is safe for health fan-in verification and carries no event payload.

func (*EventBus) Publish

func (bus *EventBus) Publish()

type FieldViolation

type FieldViolation struct {
	Field   string
	Code    string
	Message string
}

FieldViolation is an allowlisted transport validation error.

type GitHubBackend

type GitHubBackend interface {
	StartGitHubAppManifest(context.Context, string, string) (gen.GitHubManifestStart, error)
	CompleteGitHubAppManifest(context.Context, string, string) error
	ListGitHubInstallations(context.Context) (gen.GitHubInstallationList, error)
	CreateGitHubTarget(context.Context, uint64, gen.CreateGitHubTargetRequest, string) (gen.GitHubTargetMutation, error)
}

GitHubBackend is optional so existing embedders and focused API tests do not need to implement provider operations. A Controller enables it only after the credential-store and signed Manifest boundaries are initialized.

type Options

type Options struct {
	Auth    *auth.Manager
	Backend Backend
	Events  *EventBus
	UI      http.Handler
	Epoch   uint64
}

type RevisionConflict

type RevisionConflict struct {
	Expected uint64
	Current  uint64
}

RevisionConflict is the safe optimistic-lock failure returned by a Backend.

func (*RevisionConflict) Error

func (conflict *RevisionConflict) Error() string

type ValidationError

type ValidationError struct {
	Violations []FieldViolation
}

ValidationError contains no raw request or provider error.

func (*ValidationError) Error

func (validation *ValidationError) Error() string

Directories

Path Synopsis
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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