universalclient

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	Schemes []AuthScheme
}

type AuthMethod

type AuthMethod int
const (
	AuthNone AuthMethod = iota
	AuthBearer
	AuthBasic
	AuthApiKey
	AuthOAuth2
)

type AuthScheme

type AuthScheme struct {
	Method     AuthMethod
	Name       string // The name of the scheme in the OpenAPI spec
	Token      string
	Username   string
	Password   string
	ApiKeyName string
	ApiKeyIn   string // 'header' or 'query'
}

type AuthSchemeInfo

type AuthSchemeInfo struct {
	Name        string
	Type        string
	Description string
	In          string // For APIKey auth, specifies whether it's in header or query
	KeyName     string // For APIKey auth, specifies the name of the key
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents an API client generated from an OpenAPI specification

func NewClient

func NewClient(specBytes []byte, baseURL string, options ...ClientOption) (*Client, error)

NewClient creates a new API client from an OpenAPI specification

func (*Client) AsTool

func (c *Client) AsTool(operations ...string) ([]llms.Tool, error)

func (*Client) CallOperation

func (c *Client) CallOperation(operationId string, params map[string][]string, payload map[string]interface{}, headers map[string][]string) (interface{}, error)

CallOperation is CallOperationWithContext with a background context. Callers that have a request or session context should pass it, so the outbound call is cancelled with its caller and carries the caller's trace context.

func (*Client) CallOperationWithContext

func (c *Client) CallOperationWithContext(ctx context.Context, operationId string, params map[string][]string, payload map[string]interface{}, headers map[string][]string) (interface{}, error)

CallOperationWithContext invokes operationId over HTTP. The request is bound to ctx, and the W3C trace context in ctx (if any) is injected into the outbound headers so the tool backend can continue the caller's trace.

func (*Client) GetAuthSchemes

func (c *Client) GetAuthSchemes() []AuthScheme

func (*Client) GetInputSpecForOperation

func (c *Client) GetInputSpecForOperation(operationId string) (map[string]interface{}, error)

func (*Client) GetOperationBinding

func (c *Client) GetOperationBinding(operationId string) (*OperationBinding, error)

GetOperationBinding returns the HTTP binding for an operation ID.

func (*Client) GetOperationInputs

func (c *Client) GetOperationInputs(operationId string) (*OperationInputs, error)

GetOperationInputs returns the expected inputs for a given operation ID

func (*Client) GetSpec

func (c *Client) GetSpec() libopenapi.Document

func (*Client) GetSupportedAuthSchemes

func (c *Client) GetSupportedAuthSchemes() []AuthSchemeInfo

GetSupportedAuthSchemes returns information about the authentication schemes supported by the API as defined in the OpenAPI specification.

func (*Client) ListOperations

func (c *Client) ListOperations() ([]string, error)

func (*Client) SchemaToMap

func (c *Client) SchemaToMap(schema *base.Schema) map[string]interface{}

type ClientOption

type ClientOption func(*Client)

ClientOption is a function that configures a Client

func WithAuth

func WithAuth(schemeName string, credentials interface{}) ClientOption

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

WithHTTPClient sets a custom HTTP client

func WithResponseFormat

func WithResponseFormat(format ResponseFormat) ClientOption

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout sets a custom timeout for the HTTP client

type OperationBinding

type OperationBinding struct {
	OperationID string
	Method      string // upper-case HTTP method, e.g. "GET"
	Path        string // templated path, e.g. "/rate/{base}/{quote}"

	// Extensions holds the operation's x-* extensions whose value is a scalar,
	// keyed by the lower-cased extension name including the "x-" prefix.
	Extensions map[string]string
}

OperationBinding describes how an operation is bound to HTTP, along with the scalar vendor extensions declared on it. Callers that need to reason about an operation's effects - the MCP bridge derives its tool annotations this way - need the method, which is otherwise only visible inside findOperation.

type OperationInputs

type OperationInputs struct {
	PathParams  []ParameterInfo
	QueryParams []ParameterInfo
	RequestBody *RequestBodyInfo
}

OperationInputs represents the expected inputs for an operation

type ParameterInfo

type ParameterInfo struct {
	Name        string
	Description string
	Required    bool
	Schema      *base.Schema
}

ParameterInfo represents information about a parameter

type RequestBodyInfo

type RequestBodyInfo struct {
	Description string
	Required    bool
	ContentType string
	Schema      *base.Schema
}

RequestBodyInfo represents information about the request body

type ResponseFormat

type ResponseFormat int
const (
	ResponseFormatDefault ResponseFormat = iota
	ResponseFormatJSON
	ResponseFormatXML
)

Jump to

Keyboard shortcuts

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