Documentation
¶
Overview ¶
Package apiknowledgeapi is the admin REST surface for an API catalog's vendor knowledge (#2880): where the vendor's archive is and how it is kept current, checking it now, the update waiting for review, each page and automation the last import made, and hiding or restoring a page. Every change is audited with the administrator who made it. The knowledge URL is written here and never read back whole: it is shown with each query value masked.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AutomationView ¶
type AutomationView struct {
Name string `json:"name" example:"batching"`
Kind string `json:"kind" example:"library"`
Version int `json:"version,omitempty" example:"3"`
Status string `json:"status" example:"serving"`
Reason string `json:"reason,omitempty"`
Loaders map[string]int `json:"loaders,omitempty"`
}
AutomationView is one vendor automation and what the last import made of it. Loaders counts the scripts loading each version of a library.
type Config ¶
type Config struct {
Knowledge Knowledge
Service Service
Pages Pages
// CatalogExists reports whether a catalog exists.
CatalogExists func(ctx context.Context, id string) bool
// Connections is each catalog's connections as this replica serves them.
Connections func(ctx context.Context) map[string][]Connection
Author func(*http.Request) string
Audit middleware.AuditLogger
Now func() time.Time
// Mutable false registers the read alone.
Mutable bool
}
Config is what the routes read and write.
type Connection ¶
Connection is one connection reading a catalog.
type Knowledge ¶
type Knowledge interface {
Get(ctx context.Context, catalog string) (*apiknowledge.Source, error)
Put(ctx context.Context, catalog string, set apiknowledge.Settings, by string) error
Delete(ctx context.Context, catalog string) (bool, error)
Items(ctx context.Context, catalog string) ([]apiknowledge.Item, error)
History(ctx context.Context, catalog string, limit int) ([]apiknowledge.Change, error)
Pending(ctx context.Context, catalog string) (*apiknowledge.Change, error)
CurrentAutomations(ctx context.Context, catalogs []string) ([]apiknowledge.VendorAutomation, error)
Loaders(ctx context.Context, catalog, name string) (map[int]int, error)
}
Knowledge is the knowledge tables (*apiknowledge.Store).
type PageView ¶
type PageView struct {
Slug string `json:"slug" example:"limits"`
Title string `json:"title" example:"Vectorline limits"`
Version int `json:"version" example:"2"`
Status string `json:"status" example:"serving"`
Reason string `json:"reason,omitempty"`
Hidden bool `json:"hidden"`
}
PageView is one vendor page and what the last import made of it.
type Pages ¶
type Pages interface {
VendorPages(ctx context.Context, catalog string) ([]knowledgepage.VendorPageState, error)
HideVendorPage(ctx context.Context, catalog, slug string) (bool, error)
RestoreVendorPage(ctx context.Context, catalog, slug string) (bool, error)
}
Pages hides, restores and lists a catalog's vendor pages.
type Service ¶
type Service interface {
Check(ctx context.Context, catalog, trigger, by string) (apiknowledge.Result, error)
Accept(ctx context.Context, catalog, by string) (apiknowledge.Result, error)
Discard(ctx context.Context, catalog, by string) error
}
Service checks and settles updates (*apiknowledge.Service).
type SettingsRequest ¶
type SettingsRequest struct {
URL *string `json:"url,omitempty" example:"https://kb.vectorline.example/platform.tar.gz?key=abc"`
Hold bool `json:"hold"`
Interval *int `json:"refresh_interval_seconds,omitempty" example:"86400"`
}
SettingsRequest is what an administrator sets. URL omitted keeps the stored one; it is required the first time.
type View ¶
type View struct {
Catalog string `json:"catalog" example:"vectorline"`
Configured bool `json:"configured"`
// URL is the knowledge URL with each query value masked.
URL string `json:"url" example:"https://kb.vectorline.example/platform.tar.gz?key=••••••"`
Hold bool `json:"hold"`
Interval int `json:"refresh_interval_seconds" example:"86400"`
Vendor string `json:"vendor" example:"Vectorline"`
Entry string `json:"entry" example:"overview"`
LastCheckedAt *time.Time `json:"last_checked_at,omitempty"`
LastResult string `json:"last_result" example:"applied"`
LastError string `json:"last_error,omitempty"`
LastAppliedAt *time.Time `json:"last_applied_at,omitempty"`
UpdatedBy string `json:"updated_by,omitempty"`
Connections []Connection `json:"connections"`
Trusted bool `json:"trusted"`
Pages []PageView `json:"pages"`
Automations []AutomationView `json:"automations"`
Pending *apiknowledge.Change `json:"pending,omitempty"`
History []apiknowledge.Change `json:"history"`
}
View is a catalog's knowledge as an administrator sees it.