client

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: BSD-3-Clause Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FilterRegistry contains all filters available to the client.
	FilterRegistry = &provider.Registry{
		Name:         "filter",
		AllowUnknown: true,
		Providers: provider.Details{
			"jmespath": {
				Factory: provider.FactoryOf(newJMESPath),
				Defaults: map[string]string{
					"query": "@",
				},
				HelpText: "Use JMES Path to select matching JSON data",
			},
			"dig": {
				Factory: provider.FactoryOf(newDig),
				Defaults: map[string]string{
					"query": "",
				},
				HelpText: "Use a simple expression to retrieve a value",
			},
			"gotpl": {
				Factory: provider.FactoryOf(newTemplate),
				Defaults: map[string]string{
					"text": "Result: {{ .Result }}",
					"file": "",
				},
				HelpText: "Use Go template to manipulate matching data",
			},
			"json": {
				Factory: provider.FactoryOf(newJSONFilter),
				Defaults: map[string]string{
					"pretty": "false",
				},
				HelpText: "Generate JSON output",
			},
			"xpath": {
				Factory: provider.FactoryOf(newXPathFilter),
				Defaults: map[string]string{
					"query": "",
				},
				HelpText: "Apply an XPath expression",
			},
			"xml": {
				Factory:  provider.FactoryOf(newXMLFilter),
				Defaults: map[string]string{},
				HelpText: "Generate XML output",
			},
			"yaml": {
				Factory:  provider.FactoryOf(newYAMLFilter),
				Defaults: map[string]string{},
				HelpText: "Generate YAML output",
			},
			"raw": {
				Value:    NewRawFilter(),
				Defaults: map[string]string{},
				Aliases:  []string{"r", "text"},
				HelpText: "Raw text without processing",
			},
		},
	}
)

Functions

func ContextValue

func ContextValue(c *Client) cli.Action

ContextValue provides an action which sets the client into the context.

func Describe

func Describe(paramsopt ...*DescribeParams) cli.Action

Describe provides the action for describing a resource

func Do

func Do() cli.Action

Do provides the default action of the client which is to invoke it and print the results. This can be assigned to the Uses pipeline to set up necessary prerequisites. The actual action is FetchAndPrint

func FetchAndPrint

func FetchAndPrint() cli.Action

FetchAndPrint invokes the client and prints the results.

func FlagsAndArgs

func FlagsAndArgs() cli.Action

FlagsAndArgs provides an action which sets up flags and args used by the client. Despite its name, the action contributes no args.

func Import

func Import() cli.Action

Import provides the action for importing a definition

func ListFilters

func ListFilters() cli.Action

ListFilters provides an action which lists all filters available to the filter registry.

func NewFilterDownloader

func NewFilterDownloader(f Filter, d joehttpclient.Downloader, h historyGenerator) joehttpclient.Downloader

NewFilterDownloader applies the filter to an underlying downloader.

func Open

func Open() cli.Action

Open reveals a particular file or link in the editor or web browser

func SetFilter

func SetFilter(f ...*provider.Value) cli.Action

SetFilter provides an action which sets the filter which will be used in the response. This also provides an accessory flag.

func SetIncludeMetadata

func SetIncludeMetadata(f ...bool) cli.Action

func SetType

func SetType(v ...Type) cli.Action

SetType provides an action which sets the client type

Types

type Client

type Client struct {
	cli.Action
	// contains filtered or unexported fields
}

Client provides the Pastiche client, which can invoke underlying HTTP or gRPC services

func FromContext

func FromContext(c context.Context) *Client

FromContext obtains the client stored in the context

func New

func New(opts ...Option) *Client

New initializes a new client with the given set of options.

func (*Client) Apply

func (c *Client) Apply(opts ...Option)

func (*Client) SetFilter

func (c *Client) SetFilter(f Filter) error

func (*Client) SetIncludeMetadata

func (c *Client) SetIncludeMetadata(t bool) error

func (*Client) SetType

func (c *Client) SetType(t Type) error

func (*Client) Type

func (c *Client) Type() Type

Type gets the client type that was requested

type DescribeParams

type DescribeParams struct {
	*Request
}

type Filter

type Filter interface {
	Search(context.Context, Response) ([]byte, error)
}

Filter applies a search to the response data and returns the response data.

func NewDigFilter

func NewDigFilter(query string) (Filter, error)

NewDigFilter creates a filter which resolves a qualified name in a response value.

func NewJMESPathFilter

func NewJMESPathFilter(query string) (Filter, error)

NewJMESPathFilter provides a filter which uses the given query to search a data structure with JSON semantics using JMESPath.

func NewNamedOutputFilter

func NewNamedOutputFilter(name string) Filter

NewNamedOutputFilter creates a filter that resolves a named output configuration from the service resolver at runtime.

func NewRawFilter

func NewRawFilter() Filter

NewRawFilter provides a filter which does not processing

func NewTemplateFilter

func NewTemplateFilter(tpl string) (Filter, error)

NewTemplateFilter creates a filter which resolves a qualified name in a response value.

func NewXPathFilter

func NewXPathFilter(query string) (Filter, error)

NewXPathFilter generates a new XPath filter

type IncludeMetadataFilter

type IncludeMetadataFilter interface {
	Filter
	IncludeMetadata() bool
}

IncludeMetadataFilter is a filter which can request metadata be included in the response data

type Location

type Location interface {
	httpclient.Location

	Resolved() model.ResolvedResource
}

Location represents an HTTP client location and its resolved resource or operation in the configuration

type LocationResolver

type LocationResolver interface {
	httpclient.LocationResolver

	BaseURL() *url.URL
	Vars() map[string]any
}

LocationResolver represents an HTTP client location resolver

func NewServiceResolver

func NewServiceResolver(
	c *model.Model,
	root func(context.Context) *model.ServiceSpec,
	server func(context.Context) string,
	method func(context.Context) string,
) LocationResolver

NewServiceResolver creates a service resolver compatible with the client.

type Option

type Option func(*Client)

Option identifies a client option

func WithDefaultLocationResolver

func WithDefaultLocationResolver() Option

WithDefaultLocationResolver provides a client option which sets up the default location resolver, which uses the CLI arguments and flags named "service", "server", and "method"

func WithLocationResolver

func WithLocationResolver(value httpclient.LocationResolver) Option

WithLocationResolver sets the location resolver used by the client

func (Option) Execute

func (o Option) Execute(c context.Context) error

type Request

type Request struct {
	Spec   *model.ServiceSpec
	Method string
	Server string
}

type Response

type Response interface {
	Data() (any, error)
	Document() (any, error)
	Reader() io.Reader
}

type Type

type Type int

Type enumerates the client types available to Pastiche client

const (
	TypeUnspecified Type = iota
	TypeHTTP
	TypeGRPC
)

func (Type) MarshalText

func (t Type) MarshalText() ([]byte, error)

MarshalText provides the textual representation

func (Type) String

func (t Type) String() string

String produces a textual representation of the Type

func (*Type) UnmarshalText

func (t *Type) UnmarshalText(b []byte) error

UnmarshalText converts the textual representation

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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