client

package
v0.0.0-...-10b4495 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Client package provides a client that allows to interact with the a CARAVELA's daemon sending the requests to it. It can be used as a Golang SDK for the CARAVELA's. This is the same client used in the CLI github.com/ThomasPluck/caravela/cli provided.

Index

Constants

View Source
const (
	// UnknownError deals with unexpected errors.
	UnknownError = iota
	// CaravelaInstanceUnavailableError is obtained when the client tries to send a request to a CARAVELA's
	// instance that is not working e.g. because it is turned off.
	CaravelaInstanceUnavailableError
)

CARAVELA's client error codes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client holds all the necessary information to interact with CARAVELA's daemon.

func NewCaravelaIP

func NewCaravelaIP(caravelaHostIP string) *Client

NewCaravelaIP creates a new client for a CARAVELA's daemon hosted in the given IP.

func NewCaravelaTimeoutIP

func NewCaravelaTimeoutIP(caravelaHostIP string, requestTimeout time.Duration) *Client

func (*Client) ListContainers

func (c *Client) ListContainers(ctx context.Context) ([]types.ContainerStatus, *Error)

ListContainers returns a slice of container status that represent all the containers that the user have running in the CARAVELA's system.

func (*Client) Shutdown

func (c *Client) Shutdown(ctx context.Context) *Error

Shutdown makes the daemon cleanly shutdown and leave the system.

func (*Client) StopContainers

func (c *Client) StopContainers(ctx context.Context, containersIDs []string) *Error

StopContainers stops and removes all the containers given by the containersIDs slice.

func (*Client) SubmitContainers

func (c *Client) SubmitContainers(ctx context.Context, containersConfigs []types.ContainerConfig) *Error

SubmitContainers allows you to submit a set of containers that you want to deploy in the CARAVELA's system. The containers configurations are given by the containersConfigs slice.

type Configuration

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

Configuration holds the configuration parameters for the CARAVELA's client.

func DefaultConfig

func DefaultConfig(caravelaInstanceIP string) *Configuration

DefaultConfig creates a new configuration structure with the default values.

func (*Configuration) CaravelaInstanceIP

func (c *Configuration) CaravelaInstanceIP() string

CaravelaInstanceIP returns the IP address to where send the API requests.

func (*Configuration) CaravelaInstancePort

func (c *Configuration) CaravelaInstancePort() int

CaravelaInstancePort returns the port to where send the API requests.

func (*Configuration) RequestTimeout

func (c *Configuration) RequestTimeout() time.Duration

RequestTimeout returns the timeout for the API requests.

func (*Configuration) SetCaravelaInstancePort

func (c *Configuration) SetCaravelaInstancePort(newPort int)

SetCaravelaInstancePort sets the port to where send the API requests.

func (*Configuration) SetRequestTimeout

func (c *Configuration) SetRequestTimeout(newReqTimeout time.Duration)

SetRequestTimeout sets the timeout for the API requests.

type Error

type Error struct {

	// Error's code.
	Code int
	// contains filtered or unexported fields
}

Error represents the errors returned by the CARAVELA's client. It implements the error interface.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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