apichangeapi

package
v1.157.0 Latest Latest
Warning

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

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

Documentation

Overview

Package apichangeapi is the admin REST surface for keeping API catalog specs current (#2469): refreshing a spec now, how often its upstream is checked and whether a change waits for review (#2483), the upstream URL an uploaded or pasted spec is compared with (#2484), the change reports and the decision on a held one, what uses each operation (#2485), what upstreams have said about a connection's operations (#2486), and where reports and warnings are sent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(mux *http.ServeMux, wrap func(http.Handler) http.Handler, cfg Config)

Register mounts the routes behind wrap, the admin API's authentication.

Types

type Catalogs

type Catalogs interface {
	GetSpec(ctx context.Context, catalogID, specName string) (*apicatalog.SpecEntry, error)
	ListSpecs(ctx context.Context, catalogID string) ([]apicatalog.SpecEntry, error)
	ReferencingConnections(ctx context.Context, catalogID string) ([]apicatalog.ConnectionRef, error)
}

Catalogs reads specs (apicatalog.Store).

type ChangesView

type ChangesView struct {
	Changes []apichange.Change `json:"changes"`
}

ChangesView is a spec's changes, newest first.

type Config

type Config struct {
	Service  Service
	Store    Store
	Catalogs Catalogs
	// Callers answers which scripts, endpoints and prompts use operations.
	Callers func(ctx context.Context, connections []string, idx apichange.OperationIndex) (map[string][]apichange.Caller, error)
	// CatalogOf names the catalog an api connection reads, "" for none.
	CatalogOf func(ctx context.Context, connection string) string
	// Warnings lists a connection's upstream warnings.
	Warnings func(ctx context.Context, connection string) ([]apichange.Warning, error)
	// ReadSettings and SaveSettings are where reports and warnings go.
	ReadSettings func(ctx context.Context) (apichange.Settings, error)
	SaveSettings func(ctx context.Context, s apichange.Settings, by string) error
	// ChannelExists reports whether a notification channel is configured.
	ChannelExists func(ctx context.Context, name string) bool
	Author        func(*http.Request) string
	Mutable       bool
}

Config is what the routes read and write. A nil Store answers the database-backed routes 404; Mutable false registers the reads only.

type ConnectionUsedByView

type ConnectionUsedByView struct {
	Connection string       `json:"connection"`
	CatalogID  string       `json:"catalog_id,omitempty"`
	Operations []UsedByView `json:"operations"`
}

ConnectionUsedByView is what uses each of a connection's operations.

type RefreshView

type RefreshView struct {
	SpecName       string            `json:"spec_name"`
	SourceKind     string            `json:"source_kind"`
	ETag           string            `json:"etag,omitempty"`
	LastFetchedAt  string            `json:"last_fetched_at,omitempty"`
	OperationCount int               `json:"operation_count"`
	NotModified    bool              `json:"not_modified"`
	Change         *apichange.Change `json:"change,omitempty"`
}

RefreshView is what a refresh did.

type Service

type Service interface {
	Check(ctx context.Context, k apichange.SpecKey, trigger, by string) (apichange.Result, error)
	Apply(ctx context.Context, k apichange.SpecKey, id, by string) (apichange.Result, error)
	Discard(ctx context.Context, k apichange.SpecKey, id, by string) error
}

Service checks and settles changes (*apichange.Refresher).

type Store

type Store interface {
	GetWatch(ctx context.Context, k apichange.SpecKey) (apichange.Watch, error)
	SaveSettings(ctx context.Context, w apichange.Watch, by string) error
	ListChanges(ctx context.Context, k apichange.SpecKey, limit int) ([]apichange.Change, error)
	GetChange(ctx context.Context, k apichange.SpecKey, id string) (apichange.Change, error)
}

Store reads and writes watches and changes (*apichange.Store).

type UsedByView

type UsedByView struct {
	Operation string             `json:"operation"`
	UsedBy    []apichange.Caller `json:"used_by"`
}

UsedByView is what uses one operation.

type WarningsView

type WarningsView struct {
	Connection string              `json:"connection"`
	Warnings   []apichange.Warning `json:"warnings"`
}

WarningsView is what upstreams said about a connection's operations.

type WatchInput

type WatchInput struct {
	// RefreshInterval is a Go duration from 1h to 2160h (90 days), or ""
	// to check only on request.
	RefreshInterval string `json:"refresh_interval"`
	HoldChanges     bool   `json:"hold_changes"`
	// UpstreamURL is for an uploaded or pasted spec; "" for none.
	UpstreamURL string `json:"upstream_url"`
}

WatchInput is what an administrator sets.

type WatchView

type WatchView struct {
	// RefreshInterval is a Go duration ("168h"), "" when the spec is
	// never checked on a schedule.
	RefreshInterval string `json:"refresh_interval"`
	HoldChanges     bool   `json:"hold_changes"`
	UpstreamURL     string `json:"upstream_url"`
	NextCheckAt     string `json:"next_check_at,omitempty"`
	LastCheckedAt   string `json:"last_checked_at,omitempty"`
	LastError       string `json:"last_error,omitempty"`
	// PendingChange is the id of the change waiting for review, if any.
	PendingChange string `json:"pending_change,omitempty"`
	UpdatedBy     string `json:"updated_by,omitempty"`
}

WatchView is how a spec is kept current.

Jump to

Keyboard shortcuts

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