model

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: BSD-3-Clause Imports: 29 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToConfig added in v0.4.0

func ToConfig(v Item) any

ToConfig converts a model value into the corresponding configuration value.

func ToConfigFile added in v0.6.0

func ToConfigFile(m *Model) *config.File

func Validate added in v0.4.0

func Validate(m *Model) error

Types

type Auth added in v0.4.0

type Auth interface {
	// contains filtered or unexported methods
}

type BasicAuth added in v0.4.0

type BasicAuth struct {
	User     string
	Password string
}

type Client added in v0.4.0

type Client interface {
	Item
	// contains filtered or unexported methods
}

type DigOutput added in v0.4.0

type DigOutput struct {
	Query string
}

type Endpoint

type Endpoint struct {
	Name        string
	Comment     string
	Title       string
	Description string
	Tags        []string
	Method      string
	Headers     Values
	Query       Values
	Form        Values
	Links       []Link
	Body        any
	RawBody     any
	Vars        map[string]any
	Params      []*Param
	Auth        Auth
	Output      []*Output
}

type ExecSecret added in v0.6.0

type ExecSecret struct {
	Command string
}

type Expander

type Expander = expander.Interface

type FetchCall added in v0.4.0

type FetchCall struct {
	URL     string
	Options FetchOptions
}

FetchCall represents the parsed fetch call

func ParseJSFetchCall added in v0.4.0

func ParseJSFetchCall(s string) (*FetchCall, error)

func (FetchCall) ToEndpoint added in v0.4.0

func (f FetchCall) ToEndpoint() *Endpoint

type FetchOptions added in v0.4.0

type FetchOptions struct {
	Method  string            `json:"method,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
	Body    string            `json:"body,omitempty"`
}

FetchOptions represents common fetch options

type FileSecret added in v0.6.0

type FileSecret struct {
	Path                       string
	PreserveTrailingWhitespace bool
}

type Flow added in v0.5.0

type Flow struct {
	Name        string
	Comment     string
	Title       string
	Description string
	Tags        []string
	Links       []Link
	Steps       []*Step
	Vars        map[string]any
}

type GRPCClient added in v0.4.0

type GRPCClient struct {
	DisableReflection bool
	ProtoSet          string
	Plaintext         bool
}

type HTTPClient added in v0.4.0

type HTTPClient struct {
}

type Item added in v0.6.0

type Item interface {
	// contains filtered or unexported methods
}

Item is a value within the model.

type ItemKind added in v0.6.0

type ItemKind int

ItemKind enumerates the kinds of items within a model which can be searched.

const (
	ItemKindService ItemKind = iota
	ItemKindVarSet
	ItemKindMixin
	ItemKindFlow
	ItemKindResource
	ItemKindEndpoint
	ItemKindAll
)

The kinds of items we can search for. Resources and endpoints have can qualified names, but other types must have either simple name or only package qualified names

func (ItemKind) String added in v0.6.0

func (k ItemKind) String() string

String obtains the name of the kind of item, which is the same name that the corresponding search flag uses

type JMESPathOutput added in v0.4.0

type JMESPathOutput struct {
	Query string
}

type JSONOutput added in v0.4.0

type JSONOutput struct {
	Pretty bool
}
type Link struct {
	HRef       string
	HRefLang   string
	Audience   string
	Rel        string
	Title      string
	Type       string
	IsTemplate bool
}

type MergeMode added in v0.6.0

type MergeMode int

MergeMode indicates how a Value's values are combined during a reduce.

const (
	// MergeReplace replaces the existing values with the incoming ones. This
	// is the default when no merge mode is specified.
	MergeReplace MergeMode = iota

	// MergeAppend appends the incoming values to the existing ones.
	MergeAppend
)

type Mixin added in v0.6.0

type Mixin struct {
	Name        string
	Comment     string
	Title       string
	Description string
	Tags        []string
	Links       []Link
	Method      string
	Headers     Values
	Query       Values
	Form        Values
	Body        any
	RawBody     any
	Vars        map[string]any
	Auth        Auth
}

type Model

type Model struct {
	Services []*Service
	VarSets  []*VarSet
	Flows    []*Flow
	Mixins   []*Mixin
	// contains filtered or unexported fields
}

func New

func New(files ...*config.File) *Model

New creates a new model from configuration files

func (*Model) Flow added in v0.6.0

func (m *Model) Flow(name string) (*Flow, bool)

func (*Model) Mixin added in v0.6.0

func (m *Model) Mixin(name string) (*Mixin, bool)

Mixin obtains the mixin with the given name.

func (*Model) Resolve

func (m *Model) Resolve(spec ServiceSpec, server string, method string, mixins ...string) (*ResolvedResource, error)

Resolve locates the resource named by the spec, optionally within the named server and using the given request method. Any mixins which are named are applied as the last layer of the resolution.

func (*Model) Search added in v0.6.0

func (m *Model) Search(criteria *SearchCriteria) Searcher

Search provides a searcher over the items in the model which match the criteria.

func (*Model) Server added in v0.5.0

func (m *Model) Server(spec ServiceSpec) (*Server, bool)

func (*Model) Service

func (m *Model) Service(name string) (*Service, bool)

func (*Model) VarSet added in v0.5.0

func (m *Model) VarSet(name string) (*VarSet, bool)

type Output added in v0.6.1

type Output struct {
	Name            string
	Comment         string
	Title           string
	Description     string
	Links           []Link
	Filter          OutputImpl
	IncludeMetadata bool
}

type OutputImpl added in v0.6.1

type OutputImpl interface {
	// contains filtered or unexported methods
}

type Param added in v0.6.1

type Param struct {
	Name        string
	Comment     string
	Title       string
	Description string
	Tags        []string
	Links       []Link
}

type Request added in v0.4.0

type Request struct {
	URL      *url.URL
	Body     io.ReadCloser
	Headers  http.Header
	Vars     map[string]any
	Links    []Link
	Auth     Auth
	Expander e.Interface
}

func NewRequest added in v0.4.0

func NewRequest(r *ResolvedResource, opts ...RequestOption) (*Request, error)

type RequestOption added in v0.4.0

type RequestOption interface {
	// contains filtered or unexported methods
}

func WithBaseURL added in v0.4.0

func WithBaseURL(baseURL *url.URL) RequestOption

func WithContext added in v0.6.0

func WithContext(vs *VarSet) RequestOption

func WithModel added in v0.6.0

func WithModel(m *Model) RequestOption

WithModel makes the model available so that the "var" expander can resolve qualified names from any varset in the model rather than only from vars.

func WithVars added in v0.4.0

func WithVars(vars map[string]any) RequestOption

type ResolvedResource

type ResolvedResource struct {
	Service  *Service
	Resource *Resource
	Lineage  []*Resource
	Endpoint *Endpoint
	Server   *Server

	// Mixins are the mixins which were selected for the request, in the
	// order that they are applied.
	Mixins []*Mixin

	Output  []*Output
	Secrets []*Secret
	Client  Client
	Params  []*Param
	// contains filtered or unexported fields
}

ResolvedResource represents the resource which was selected by its name

type Resource

type Resource struct {
	Name        string
	Comment     string
	Title       string
	Description string
	Tags        []string
	Resources   []*Resource
	Endpoints   []*Endpoint
	URITemplate *uritemplates.URITemplate
	Headers     Values
	Query       Values
	Form        Values
	Links       []Link
	Command     []string
	Body        any
	RawBody     any
	Vars        map[string]any
	Params      []*Param
	Auth        Auth
	Output      []*Output
}

func (*Resource) Endpoint

func (r *Resource) Endpoint(m string) (*Endpoint, bool)

func (*Resource) Resource

func (r *Resource) Resource(name string) (*Resource, bool)

type SearchCriteria added in v0.6.0

type SearchCriteria struct {
	// Spec names the items to search for.  For var sets, services, and flows,
	// the spec must be just a name because these don't nest, but for resources
	// or endpoints, this could be a qualifying name.  When the spec is empty,
	// all items of the given kind are considered.
	Spec *ServiceSpec

	// Kind identifies which kind of item is searched for.
	Kind ItemKind

	// IncludeTags filters items to those which have all of these tags.  When
	// empty, no filtering on tags occurs.
	IncludeTags []string

	// Method filters endpoints to those which use this request method.  It is
	// only relevant to endpoints.
	Method string
}

SearchCriteria is the union of all of the criteria which are relevant to each kind of searcher.

type Searcher added in v0.6.0

type Searcher interface {
	Results() (iter.Seq[Item], error)
}

Searcher enumerates the items within a model which match a search criteria.

type Secret added in v0.6.0

type Secret struct {
	Name        string
	Comment     string
	Title       string
	Description string
	Links       []Link
	Provider    SecretProvider
}

type SecretProvider added in v0.6.0

type SecretProvider interface {
	// contains filtered or unexported methods
}

type Server

type Server struct {
	Name        string
	Comment     string
	Description string
	Tags        []string
	Title       string
	BaseURL     string
	Headers     Values
	Query       Values
	Form        Values
	Links       []Link
	Vars        map[string]any
	Params      []*Param
	Auth        Auth
	Output      []*Output
	Secrets     []*Secret
}

type Service

type Service struct {
	Name        string
	Comment     string
	Title       string
	Description string
	Tags        []string
	Servers     []*Server
	Links       []Link
	Resource    *Resource
	Vars        map[string]any
	Params      []*Param
	Client      Client
	Auth        Auth
	Output      []*Output
	Secrets     []*Secret
}

func (*Service) Server

func (s *Service) Server(name string) (*Server, bool)

type ServiceSpec

type ServiceSpec []string

func ParseServiceSpec added in v0.5.0

func ParseServiceSpec(text string) (ServiceSpec, error)

ParseServiceSpec parses a service spec

func (ServiceSpec) NewCounter

func (s ServiceSpec) NewCounter() cli.ArgCounter

func (ServiceSpec) Path

func (s ServiceSpec) Path() string

func (ServiceSpec) ServiceName

func (s ServiceSpec) ServiceName() string

func (*ServiceSpec) Set

func (s *ServiceSpec) Set(arg string) error

func (ServiceSpec) String

func (s ServiceSpec) String() string

type SpecStep added in v0.5.0

type SpecStep struct {
	Spec ServiceSpec
}

type Step added in v0.5.0

type Step struct {
	Name        string
	Comment     string
	Title       string
	Description string
	Tags        []string
	Links       []Link
	Method      string
	Headers     Values
	Form        Values
	Body        any
	RawBody     any
	Vars        map[string]any
	Step        StepImpl
}

type StepImpl added in v0.6.1

type StepImpl interface {
	// contains filtered or unexported methods
}

type TSVOutput added in v0.5.0

type TSVOutput struct {
	Fields   []string
	Dig      string
	JMESPath string
	Comma    string
	UseCRLF  bool
}

type TableOutput added in v0.5.0

type TableOutput struct {
	Fields              []string
	Dig                 string
	JMESPath            string
	MinWidth            int
	TabWidth            int
	Padding             int
	PadChar             string
	FilterHTML          bool
	AlignRight          bool
	Debug               bool
	StripEscape         bool
	DiscardEmptyColumns bool
}

type TemplateOutput added in v0.4.0

type TemplateOutput struct {
	Text string
	File string
}

type URLStep added in v0.5.0

type URLStep struct {
	URL string
}

type Value added in v0.6.0

type Value struct {
	Name     string
	Value    string
	Values   []string
	Optional bool
	Merge    MergeMode
}

Value is a single named value or list of values within Values.

type Values added in v0.6.0

type Values []Value

Values is a list of named values. It mirrors config.Values within the model and provides the reduce semantics used when resolving values across the service, server, resource, and endpoint layers.

func (Values) Reduce added in v0.6.0

func (v Values) Reduce(next Values) Values

Reduce combines the receiver with the more-specific next values, honoring each incoming value's merge mode. A value with the same name is appended to or replaces the existing one; a value with a new name is added.

func (Values) ToHeader added in v0.6.0

func (v Values) ToHeader() http.Header

ToHeader converts the values into a net/http.Header.

func (Values) ToURLValues added in v0.6.0

func (v Values) ToURLValues() url.Values

ToURLValues converts the values into a url.Values.

type VarSet added in v0.5.0

type VarSet struct {
	Name        string
	Comment     string
	Title       string
	Description string
	Tags        []string
	Links       []Link
	Vars        map[string]map[string]any
}

func (*VarSet) Resolve added in v0.6.0

func (v *VarSet) Resolve(target, path string) (any, bool)

Resolve looks up the value used to fill the variable named target, at the given dotted path within the varset. The first path segment names a group within Vars. When the path names only the group, the property within that group whose name matches target is used instead.

type WebSocketClient added in v0.6.0

type WebSocketClient struct {
}

type XMLOutput added in v0.4.0

type XMLOutput struct {
	Pretty bool
}

type XPathOutput added in v0.4.0

type XPathOutput struct {
	Query string
}

type YAMLOutput added in v0.4.0

type YAMLOutput struct {
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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