catalog

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindRead   Kind = "read"
	KindCreate Kind = "create"
	KindUpdate Kind = "update"
	KindDelete Kind = "delete"
	KindAction Kind = "action"

	SideEffectNone        SideEffect = "none"
	SideEffectWrite       SideEffect = "write"
	SideEffectDestructive SideEffect = "destructive"

	// ExposureDirect is a pinned tool. ExposureGrouped is one tool for the resource. ExposureDiscovery stays on search and describe.
	ExposureDirect    = "direct"
	ExposureGrouped   = "grouped"
	ExposureDiscovery = "discovery-only"
)
View Source
const (
	NodeResource  NodeKind = "resource"
	NodeOperation NodeKind = "operation"
	NodeSchema    NodeKind = "schema"

	EdgeOwns    = "owns"
	EdgeUses    = "uses"
	EdgeLinks   = "links"
	EdgeRelates = "relates"
)

Variables

This section is empty.

Functions

func ApplyRelations

func ApplyRelations(cat *Catalog, rels []Relation) error

A field name in a spec does not create an edge. This declaration does.

func Facts

func Facts(cat *Catalog) map[string]OpFact

func SurfaceRegressions

func SurfaceRegressions(base, next map[string]OpFact, confirmationChanged map[string]bool, confirmationOff bool) []string

confirmationChanged lists operations whose agent.yaml confirmation field changed on purpose.

Types

type Auth

type Auth struct {
	Name       string   `json:"Name"`
	Header     string   `json:"Header"`
	Query      string   `json:"Query"`
	Kind       string   `json:"Kind"`
	Scopes     []string `json:"Scopes"`
	UserHeader string   `json:"UserHeader"`
	Type       string   `json:"-"` // OpenAPI security scheme type
	Scheme     string   `json:"-"` // OpenAPI http scheme, such as basic
}

Auth is one scheme in a security requirement. Header is set for header placement. Query is set for an apiKey in query. UserHeader is set when the contract names a separate header for the person token.

type Catalog

type Catalog struct {
	Title      string
	Version    string
	Operations []Operation
	Links      []OpLink
	Uses       []SchemaUse
	Graph      Graph
	// contains filtered or unexported fields
}

func Merge

func Merge(parts ...*Catalog) (*Catalog, error)

func (*Catalog) ByID

func (c *Catalog) ByID(id string) *Operation

func (*Catalog) ClearConfirmation

func (c *Catalog) ClearConfirmation()

ClearConfirmation turns the confirmation gate off for every operation.

func (*Catalog) Finalize

func (c *Catalog) Finalize()

func (*Catalog) IndexLine

func (c *Catalog) IndexLine() string

func (*Catalog) Joins

func (c *Catalog) Joins() []string

func (*Catalog) SelectServer

func (c *Catalog) SelectServer(name string) error

type Edge

type Edge struct {
	From string
	To   string
	Kind string
	Note string
}

Owns is resource to operation. Uses is operation to schema. Links is operation to operation.

type Graph

type Graph struct {
	Nodes []Node
	Edges []Edge
}

func BuildGraph

func BuildGraph(ops []Operation, links []OpLink, uses []SchemaUse) Graph

func (Graph) OperationsForResource

func (g Graph) OperationsForResource(resource string) []string

func (Graph) Related

func (g Graph) Related(operationID string) []string

func (Graph) Schemas

func (g Graph) Schemas(operationID string) []string

type Kind

type Kind string

type Match

type Match struct {
	Operation Operation `json:"Operation"`
	Related   []string  `json:"Related"`
}
func Search(cat *Catalog, query string, synonyms map[string][]string) []Match

An exact id outranks a synonym. A synonym outranks a weaker substring.

func SearchPage

func SearchPage(cat *Catalog, query string, synonyms map[string][]string, offset, limit int) []Match

type Node

type Node struct {
	ID   string
	Name string
	Kind NodeKind
}

type NodeKind

type NodeKind string

type OpFact

type OpFact struct {
	Confirmation bool     `json:"confirmation"`
	Destructive  bool     `json:"destructive"`
	Referenced   bool     `json:"referenced"`
	Callable     *bool    `json:"callable,omitempty"`
	Permissions  []string `json:"permissions,omitempty"`
}
type OpLink struct {
	From   string
	To     string
	Note   string
	Params map[string]string
}

type Operation

type Operation struct {
	ID                   string            `json:"ID"`
	Name                 string            `json:"Name"`
	Summary              string            `json:"-"`
	Description          string            `json:"Description"`
	IDFallback           bool              `json:"-"`
	IDCollision          string            `json:"-"`
	Group                string            `json:"Group"`
	Kind                 Kind              `json:"Kind"`
	Method               string            `json:"Method"`
	PathTemplate         string            `json:"PathTemplate"`
	Params               []Param           `json:"Params"`
	ResponseSummary      string            `json:"ResponseSummary"`
	SideEffect           SideEffect        `json:"SideEffect"`
	RequiresConfirmation bool              `json:"RequiresConfirmation"`
	Permissions          []string          `json:"Permissions"`
	Idempotency          string            `json:"Idempotency"`
	Retry                string            `json:"Retry"`
	Exposure             string            `json:"Exposure"`
	BaseURL              string            `json:"BaseURL"`
	Servers              []Server          `json:"Servers"`
	Page                 map[string]string `json:"Page"`
	Auth                 []Auth            `json:"Auth"`
	Requirements         [][]Auth          `json:"Requirements"` // OR of AND groups. Auth is the first group.
	Tags                 []string          `json:"Tags"`
	ResponseFields       []string          `json:"ResponseFields"`
}

func (Operation) AuthSchemes

func (op Operation) AuthSchemes() []Auth

AuthSchemes returns each scheme name once, across every requirement.

func (Operation) BodyParam

func (op Operation) BodyParam() (Param, bool)

type Param

type Param struct {
	Name        string `json:"Name"`
	In          string `json:"In"` // path, query, header, body
	Required    bool   `json:"Required"`
	Description string `json:"Description"`
	Schema      string `json:"Schema"`
	MediaType   string `json:"MediaType"`
	Default     string `json:"Default"`
	Style       string `json:"Style"`
	Explode     bool   `json:"Explode"`
}

type Relation

type Relation struct {
	Schema string `yaml:"schema"`
	Field  string `yaml:"field"`
	To     string `yaml:"to"`
}

func ParseRelations

func ParseRelations(data []byte) ([]Relation, error)

type SchemaUse

type SchemaUse struct {
	OperationID string
	Name        string
}

type Server

type Server struct {
	URL  string `json:"URL"`
	Name string `json:"Name"`
}

type SideEffect

type SideEffect string

Jump to

Keyboard shortcuts

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