sandboxesapi

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SizeSmall  = "small"
	SizeMedium = "medium"
	SizeLarge  = "large"
)
View Source
const (
	TypeSnowflake = "snowflake"
	TypePython    = "python"
	TypeR         = "r"
)
View Source
const Component = "keboola.sandboxes"
View Source
const TimeFormat = "2006-01-02T15:04:05Z"

TimeFormat used in Sandbox API

Variables

View Source
var SizesOrdered = []string{
	SizeSmall,
	SizeMedium,
	SizeLarge,
}
View Source
var TypesOrdered = []string{
	TypeSnowflake,
	TypePython,
	TypeR,
}

Functions

func ClientWithHost

func ClientWithHost(c client.Client, apiHost string) client.Client

ClientWithHost returns HTTP client with api host set.

func ClientWithHostAndToken

func ClientWithHostAndToken(c client.Client, apiHost, apiToken string) client.Client

ClientWithHostAndToken returns HTTP client with api host and token set.

func ClientWithToken

func ClientWithToken(c client.Client, apiToken string) client.Client

ClientWithToken returns HTTP client with api token set.

func Create

func Create(
	ctx context.Context,
	sapiClient client.Sender,
	queueClient client.Sender,
	branchId BranchID,
	sandboxName string,
	sandboxType string,
	opts ...Option,
) (*storageapi.Config, error)

func CreateConfigRequest

func CreateConfigRequest(branchId BranchID, name string) client.APIRequest[*storageapi.ConfigWithRows]

func CreateJobRequest

func CreateJobRequest(configId ConfigID, sandboxType string, opts ...Option) client.APIRequest[client.NoResult]

func Delete

func Delete(
	ctx context.Context,
	sapiClient client.Sender,
	queueClient client.Sender,
	branchId BranchID,
	configId ConfigID,
	sandboxId SandboxID,
) error

func DeleteConfigRequest

func DeleteConfigRequest(branchId BranchID, configId ConfigID) client.APIRequest[client.NoResult]

func DeleteJobRequest

func DeleteJobRequest(configId ConfigID, sandboxId SandboxID) client.APIRequest[client.NoResult]

func GetConfigRequest

func GetConfigRequest(branchId BranchID, configId ConfigID) client.APIRequest[*storageapi.Config]

func GetRequest

func GetRequest(sandboxId SandboxID) client.APIRequest[*Sandbox]

func ListConfigRequest

func ListConfigRequest(branchId BranchID) client.APIRequest[*[]*storageapi.Config]

func ListRequest

func ListRequest() client.APIRequest[*[]*Sandbox]

func SupportsSizes

func SupportsSizes(typ string) bool

Types

type BranchID

type BranchID = storageapi.BranchID

type ConfigID

type ConfigID = storageapi.ConfigID

type Details

type Details struct {
	Connection struct {
		Database  string `json:"database"`
		Schema    string `json:"schema"`
		Warehouse string `json:"warehouse"`
	} `json:"connection"`
}

type DurationSeconds

type DurationSeconds time.Duration

DurationSeconds is time.Duration encoded/decoded as number of seconds.

func (DurationSeconds) MarshalJSON

func (d DurationSeconds) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding.

func (DurationSeconds) String

func (d DurationSeconds) String() string

func (*DurationSeconds) UnmarshalJSON

func (d *DurationSeconds) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements JSON decoding.

type Error

type Error struct {
	Message   string `json:"messsage"`
	ErrorInfo string `json:"error"`
	// contains filtered or unexported fields
}

Error represents the structure of Storage API error.

func (Error) Error

func (e Error) Error() string

func (Error) ErrorName

func (e Error) ErrorName() string

ErrorName returns a human-readable name of the error.

func (Error) ErrorUserMessage

func (e Error) ErrorUserMessage() string

ErrorUserMessage returns error message for end user.

func (*Error) SetRequest

func (e *Error) SetRequest(request *http.Request)

SetRequest method allows injection of HTTP request to the error, it implements client.errorWithRequest.

func (*Error) SetResponse

func (e *Error) SetResponse(response *http.Response)

SetResponse method allows injection of HTTP response to the error, it implements client.errorWithResponse.

func (Error) StatusCode

func (e Error) StatusCode() int

StatusCode returns HTTP status code.

type Option

type Option func(p *params)

func WithExpireAfterHours

func WithExpireAfterHours(v uint64) Option

func WithImageVersion

func WithImageVersion(v string) Option

func WithShared

func WithShared(v bool) Option

func WithSize

func WithSize(v string) Option

type Sandbox

type Sandbox struct {
	ID       SandboxID `json:"id"`
	Type     string    `json:"type"`
	Size     string    `json:"size"` // Only exists for container sandboxes (Python, R)
	Active   bool      `json:"active"`
	Shared   bool      `json:"shared"`
	User     string    `json:"user"`
	Host     string    `json:"host"`
	Url      string    `json:"url"`
	Password string    `json:"password"`
	Created  Time      `json:"createdTimestamp"`
	Updated  Time      `json:"updatedTimestamp"`
	Start    Time      `json:"startTimestamp"`
	// Workspace details - only exists for Snowflake sandboxes
	Details *Details `json:"workspaceDetails"`
}

type SandboxID

type SandboxID string

func GetSandboxID

func GetSandboxID(c *storageapi.Config) (SandboxID, error)

func (SandboxID) String

func (v SandboxID) String() string

type Time

type Time time.Time

Time is encoded/decoded in TimeFormat used in Sandbox API.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding.

func (Time) String

func (t Time) String() string

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements JSON decoding.

Jump to

Keyboard shortcuts

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