api

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAPIAddress = "https://127.0.0.1:9090"

Variables

This section is empty.

Functions

func HasLogLevel added in v0.2.0

func HasLogLevel(l, level LogLevel) bool

func ReadResponse

func ReadResponse(response *http.Response, data interface{}) error

ReadResponse is an helper function that allow to fully read and close a response body and unmarshal its json content into a provided data structure. If response status code is greater or equal to 400 it automatically parse an error response and returns it as a non-nil error.

func ReadTextResponse

func ReadTextResponse(response *http.Response) ([]byte, error)

Types

type Configuration

type Configuration struct {
	APIURL        string `mapstructure:"api_url"`
	SkipTLSVerify bool   `mapstructure:"skip_tls_verify"`
	KeyFile       string `mapstructure:"key_file"`
	CertFile      string `mapstructure:"cert_file"`
	CAFile        string `mapstructure:"ca_file"`
	CAPath        string `mapstructure:"ca_path"`
	User          string `mapstructure:"user"`
	AccessToken   string `mapstructure:"access_token"`

	HttpClient *http.Client
}

Configuration holds the api client configuration

type Error

type Error struct {
	ID     string `json:"id"`
	Status int    `json:"status"`
	Title  string `json:"title"`
	Detail string `json:"detail"`
}

Error represent an error returned by the REST API

func (*Error) Error

func (e *Error) Error() string

type Errors

type Errors struct {
	Errors []*Error `json:"errors"`
}

Errors is a collection of REST errors

func (*Errors) Error

func (es *Errors) Error() string

type Execution

type Execution struct {
	ID      string                 `json:"id"`
	Status  string                 `json:"status"`
	Outputs map[string]interface{} `json:"outputs,omitempty"`
}

Execution is the response structure of a GetExecution operation

type ExecutionLogs added in v0.2.0

type ExecutionLogs struct {
	Logs         []Log `json:"logs"`
	TotalResults int   `json:"total_results"`
	From         int   `json:"from"`
}

ExecutionLogs is the response structure of a GetExecutionLog operation

type ExecutionsService

type ExecutionsService interface {
	Status(ctx context.Context, executionID string) (Execution, error)
	Logs(ctx context.Context, executionID string, opts *LogsRequestOpts) (ExecutionLogs, error)
	Cancel(ctx context.Context, executionID string) error
}

type HTTPClient

type HTTPClient interface {
	NewRequest(ctx context.Context, method, path string, body io.Reader) (*http.Request, error)
	Do(req *http.Request) (*http.Response, error)

	Workflows() WorkflowsService
	Executions() ExecutionsService
	SSHKeys() SSHKeysService
}

HTTPClient represents an HTTP client

func GetClient

func GetClient(cc Configuration) (HTTPClient, error)

GetClient returns a HTTP Client

type Log added in v0.2.0

type Log struct {
	Level     string    `json:"level"`
	Timestamp time.Time `json:"timestamp"`
	Content   string    `json:"content"`
}

Log represents the log entry return by the a4c rest api

type LogLevel added in v0.2.0

type LogLevel uint8

LogLevel

const (
	DEBUG LogLevel = 1 << iota
	INFO
	WARN
	ERROR
)

func ClearLogLevels added in v0.2.0

func ClearLogLevels(l LogLevel, levels ...LogLevel) LogLevel

func SetLogLevels added in v0.2.0

func SetLogLevels(l LogLevel, levels ...LogLevel) LogLevel

type LogsRequestOpts added in v0.2.0

type LogsRequestOpts struct {
	FromIndex *int
	Size      *int
	Timeout   time.Duration
	Levels    LogLevel
}

type SSHKey

type SSHKey struct {
	ID        string `json:"id"`
	PublicKey string `json:"public_key"`
}

SSHKey is the response structure of a CreateKey operation for a given user

The response contains only the public key, private key is never disclosed

type SSHKeyGenerationRequest

type SSHKeyGenerationRequest struct {
	MetaData map[string]interface{} `json:"metadata,omitempty"`
}

SSHKeyGenerationRequest is the request structure of a CreateKey operation

type SSHKeysService

type SSHKeysService interface {
	GenerateSSHKey(ctx context.Context, genRequest SSHKeyGenerationRequest) (SSHKey, error)
}

type Workflow

type Workflow struct {
	ID              string `json:"id"`
	Name            string `json:"name"`
	ApplicationID   string `json:"application_id"`
	EnvironmentID   string `json:"environment_id"`
	EnvironmentName string `json:"environment_name"`
}

type WorkflowInputs

type WorkflowInputs struct {
	Inputs map[string]interface{} `json:"inputs"`
}

WorkflowInputs is the payload send when triggering a workflow execution

type Workflows

type Workflows struct {
	Workflows []Workflow `json:"workflows"`
}

Workflows is the response structure of a GetWorkflows operation

type WorkflowsService

type WorkflowsService interface {
	List(ctx context.Context) (Workflows, error)
	Trigger(ctx context.Context, workflowID string, inputs *WorkflowInputs) (string, error)
}

Jump to

Keyboard shortcuts

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