client

package
v1.5.0-alpha3 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialAsyncResult added in v1.2.3

func DialAsyncResult[In apimodels.Request, Out any](
	ctx context.Context,
	client Client,
	endpoint string,
	r In,
) (<-chan *concurrency.AsyncResult[Out], error)

DialAsyncResult makes a Dial call to the passed client and interprets any received messages as AsyncResult objects, decoding them and posting them on the returned channel.

Types

type API added in v1.2.2

type API interface {
	Agent() *Agent
	Auth() *Auth
	Jobs() *Jobs
	Nodes() *Nodes
}

API is the root of the Bacalhau server API. The structure mirrors the structure of the API: each method returns an object that can submit requests to control a single part of the system.

func New

func New(address string, optFns ...OptionFn) API

func NewAPI added in v1.2.2

func NewAPI(transport Client) API

type Agent

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

func (*Agent) Alive

func (c *Agent) Alive(ctx context.Context) (*apimodels.IsAliveResponse, error)

Alive is used to check if the agent is alive.

func (*Agent) Node

Node is used to get the agent node info.

func (*Agent) Version

func (c *Agent) Version(ctx context.Context) (*apimodels.GetVersionResponse, error)

Version is used to get the agent version.

type Auth added in v1.2.1

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

func (*Auth) Authenticate added in v1.2.1

func (auth *Auth) Authenticate(ctx context.Context, r *apimodels.AuthnRequest) (*apimodels.AuthnResponse, error)

func (*Auth) Methods added in v1.2.1

type AuthenticatingClient added in v1.2.2

type AuthenticatingClient struct {
	Client Client

	// Credential should be any existing client credential for the user. It is
	// allowed to be nil, representing no existing client credential.
	Credential *apimodels.HTTPCredential

	// PersistCredential will be called when the system should remember a new
	// auth token for a user. The supplied auth token may be nil, in which case
	// any existing tokens should be deleted.
	PersistCredential func(*apimodels.HTTPCredential) error

	// Authenticate will be called when the system should run an authentication
	// flow using the passed Auth API.
	Authenticate func(context.Context, *Auth) (*apimodels.HTTPCredential, error)
}

AuthenticatingClient is a client implementation that will automatically run user authentication when a new authorization token is required. This is either when the user does not yet have an authorization token that matches the remote server or if the token is used but the server says it is invalid (e.g. because it has expired).

Since authentication is normally an interactive affair, this client requires an authentication callback that will be called to actually authenticate.

Authorization tokens can be optionally persisted by supplying a callback. This client will keep track of any authorization tokens it collects.

func (*AuthenticatingClient) Delete added in v1.2.2

func (*AuthenticatingClient) Dial added in v1.2.3

func (t *AuthenticatingClient) Dial(
	ctx context.Context,
	path string,
	in apimodels.Request,
) (<-chan *concurrency.AsyncResult[[]byte], error)

func (*AuthenticatingClient) Get added in v1.2.2

func (*AuthenticatingClient) List added in v1.2.2

func (*AuthenticatingClient) Post added in v1.2.2

func (*AuthenticatingClient) Put added in v1.2.2

type Client

Client is the object that makes transport-level requests to specified APIs. Users should make use of the `API` object for a higher level interface.

func NewHTTPClient added in v1.2.2

func NewHTTPClient(address string, optFns ...OptionFn) Client

New creates a new transport.

type Config added in v1.2.1

type Config struct {
	// Namespace is the default namespace to use for all requests.
	Namespace string

	// The optional application specific identifier appended to the User-Agent header.
	AppID string

	// HTTPClient is the client to use. Default will be used if not provided.
	// If set, other configuration options will be ignored, such as Timeout
	HTTPClient *http.Client

	// Timeout is the timeout for requests.
	Timeout time.Duration

	// Headers is a map of headers to add to all requests.
	Headers http.Header

	// TLSConfig provides info on how we want to use TLS
	TLS TLSConfig

	// WebsocketChannelBuffer is the size of the channel buffer for websocket messages
	WebsocketChannelBuffer int
}

func DefaultConfig added in v1.2.2

func DefaultConfig() Config

DefaultConfig returns a default configuration for the client.

type Jobs

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

func (*Jobs) Executions

Executions returns executions for a job.

func (*Jobs) Get

Get is used to get a job by ID.

func (*Jobs) History

History returns history events for a job.

func (*Jobs) List

List is used to list all jobs in the cluster.

func (*Jobs) Logs added in v1.2.2

Logs returns a stream of logs for a given job/execution.

func (*Jobs) Put

Put is used to submit a new job to the cluster, or update an existing job with matching ID.

func (*Jobs) Results

Results returns results for a job.

func (*Jobs) Stop

Stop is used to stop a job by ID.

type Nodes

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

func (*Nodes) Get

Get is used to get a node by ID.

func (*Nodes) List

List is used to list all nodes in the cluster.

func (*Nodes) Put added in v1.3.0

Put is used to update a node's state with a node action (pause, drain, approve etc)

type OptionFn

type OptionFn func(*Config)

OptionFn is a function that can be used to configure the client.

func WithAppID

func WithAppID(appID string) OptionFn

WithAppID sets the optional application specific identifier appended to the User-Agent header.

func WithCACertificate added in v1.2.1

func WithCACertificate(cacert string) OptionFn

CACert specifies the location of a CA certificate file so that it is possible to use TLS without the insecure flag when the server uses a self-signed certificate

func WithHTTPClient

func WithHTTPClient(client *http.Client) OptionFn

WithHTTPClient sets the client to use. Default will be used if not provided. If set, other configuration options will be ignored, such as Timeout

func WithHeaders

func WithHeaders(headers http.Header) OptionFn

WithHeaders sets the headers to add to all requests.

func WithInsecureTLS added in v1.2.1

func WithInsecureTLS(insecure bool) OptionFn

Insecure activates TLS but does not verify any certificate

func WithNamespace

func WithNamespace(namespace string) OptionFn

WithNamespace sets the default namespace to use for all requests.

func WithTLS added in v1.2.1

func WithTLS(active bool) OptionFn

UseTLS denotes whether to use TLS or not

func WithTimeout

func WithTimeout(timeout time.Duration) OptionFn

WithTimeout sets the timeout for requests.

func WithWebsocketChannelBuffer added in v1.2.2

func WithWebsocketChannelBuffer(buffer int) OptionFn

WithWebsocketChannelBuffer sets the size of the channel buffer for websocket messages

type TLSConfig added in v1.2.1

type TLSConfig struct {
	// UseTLS denotes whether to use TLS or not
	UseTLS bool
	// Insecure activates TLS but does not verify any certificate
	Insecure bool
	// CACert specifies the location of a self-signed CA certificate
	// file
	CACert string
}

type UnexpectedResponseError

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

UnexpectedResponseError tracks the components for API errors encountered when requireOK and requireStatusIn's conditions are not met.

func (UnexpectedResponseError) Additional

func (e UnexpectedResponseError) Additional() error

func (UnexpectedResponseError) Body

func (UnexpectedResponseError) Error

func (e UnexpectedResponseError) Error() string

func (UnexpectedResponseError) ExpectedStatuses

func (e UnexpectedResponseError) ExpectedStatuses() []int

func (UnexpectedResponseError) HasAdditional

func (e UnexpectedResponseError) HasAdditional() bool

func (UnexpectedResponseError) HasBody

func (e UnexpectedResponseError) HasBody() bool

func (UnexpectedResponseError) HasError

func (e UnexpectedResponseError) HasError() bool

func (UnexpectedResponseError) HasStatusCode

func (e UnexpectedResponseError) HasStatusCode() bool

func (UnexpectedResponseError) HasStatusText

func (e UnexpectedResponseError) HasStatusText() bool

func (UnexpectedResponseError) StatusCode

func (e UnexpectedResponseError) StatusCode() int

func (UnexpectedResponseError) StatusText

func (e UnexpectedResponseError) StatusText() string

func (UnexpectedResponseError) Unwrap

func (e UnexpectedResponseError) Unwrap() error

Jump to

Keyboard shortcuts

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