http

package
v0.5.0-rc.8 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 42 Imported by: ? modules, 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

View Source
var (
	// ErrInvalidConfig indicates HTTP connector configuration is invalid.
	ErrInvalidConfig = xerror.InvalidInput(xerror.DataSource)
	// ErrInvalidCredentials indicates HTTP connector credentials are invalid.
	ErrInvalidCredentials = xerror.InvalidInput(xerror.DataSource)
)

Functions

func ValidateCredentials

func ValidateCredentials(creds Credentials) error

ValidateCredentials keeps the service and runtime authentication boundary consistent.

Types

type Config

type Config struct {
	BaseURL                    string `json:"base_url"                                validate:"required,url"`
	HealthPath                 string `json:"health_path,omitempty"`
	TimeoutSeconds             int    `json:"timeout_seconds,omitempty"               validate:"omitempty,min=1,max=300"`
	OpenAPIURL                 string `json:"openapi_url,omitempty"                   validate:"omitempty,url"`
	OpenAPIFetchTimeoutSeconds int    `json:"openapi_fetch_timeout_seconds,omitempty" validate:"omitempty,min=1,max=60"`
	AllowPrivateHosts          bool   `json:"allow_private_hosts,omitempty"`
}

Config holds configuration for HTTP data source connectivity checks and schema introspection.

type Connector

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

Connector validates HTTP connectivity by sending a request to a configured endpoint.

func New

func New(ctx context.Context, config Config, creds Credentials) (*Connector, error)

New creates a new HTTP connector.

func (*Connector) Close

func (c *Connector) Close() error

Close releases connector resources.

func (*Connector) Execute

func (c *Connector) Execute(
	ctx context.Context,
	queryData json.RawMessage,
	params map[string]types.TypedParam,
	limits ...types.ExecutionLimits,
) (*result.ExecutionResult, error)

Execute executes an HTTP request described by queryData with the provided parameters.

queryData must be a JSON object with at minimum "method" and "path" fields. params are injected into the query_params, headers, or body structure as specified in queryData.

func (*Connector) IntrospectSchema

func (c *Connector) IntrospectSchema(ctx context.Context) (*HTTPSchema, error)

IntrospectSchema retrieves and parses the OpenAPI schema from the configured OpenAPIURL.

func (*Connector) TestConnection

func (c *Connector) TestConnection(ctx context.Context) error

TestConnection performs the configured HTTP request and validates response status.

type Credentials

type Credentials struct {
	// OAuthDestination is an internal runtime binding emitted only by credentialssvc.
	OAuthDestination string            `json:"oauth_destination,omitempty"`
	BearerToken      string            `json:"bearer_token,omitempty"`
	Username         string            `json:"username,omitempty"`
	Password         string            `json:"password,omitempty"`
	APIKey           string            `json:"api_key,omitempty"`
	APIKeyHeader     string            `json:"api_key_header,omitempty"`
	SecretHeaders    map[string]string `json:"secret_headers,omitempty"`
}

Credentials holds authentication settings for HTTP endpoints.

type HTTPSchema

type HTTPSchema struct {
	Operations []Operation `json:"operations"`
}

HTTPSchema represents the extracted schema from an OpenAPI specification.

type HTTPSchemaIntrospector

type HTTPSchemaIntrospector interface {
	IntrospectSchema(ctx context.Context) (*HTTPSchema, error)
}

HTTPSchemaIntrospector defines the interface for HTTP connector schema introspection.

type OpenAPIFormat

type OpenAPIFormat string

OpenAPIFormat represents the format of an OpenAPI specification file.

const (
	OpenAPIFormatJSON OpenAPIFormat = "json"
	OpenAPIFormatYAML OpenAPIFormat = "yaml"
)

type Operation

type Operation struct {
	OperationID string          `json:"operation_id"`           // Unique identifier (e.g., "listUsers")
	Path        string          `json:"path"`                   // API path (e.g., "/users")
	Method      string          `json:"method"`                 // HTTP method (GET, POST, PUT, DELETE, PATCH)
	Description string          `json:"description"`            // Human-readable description
	Parameters  json.RawMessage `json:"parameters,omitempty"`   // Parameter schema (JSON)
	RequestBody json.RawMessage `json:"request_body,omitempty"` // Request body schema (JSON)
	Responses   json.RawMessage `json:"responses,omitempty"`    // Response schemas (JSON)
	Draft       json.RawMessage `json:"draft,omitempty"`
	Diagnostics []string        `json:"diagnostics,omitempty"`
}

Operation represents a single HTTP operation (endpoint) from an OpenAPI spec.

Jump to

Keyboard shortcuts

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