client

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2023 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFunctionMaxRetry   = 5
	DefaultFunctionMaxTimeout = time.Duration(time.Minute * 1)
)
View Source
const (
	PostgresIntegrationType = "postgres"
)

Variables

View Source
var (
	// ErrTimeout           = errgo.New("Operation aborted. Timeout occured")
	// ErrMaxRetriesReached = errgo.New("Operation aborted. Too many errors.")
	ErrTimeout           = errors.New("timeout occured")
	ErrMaxRetriesReached = errors.New("too many errors")
)

Functions

func Do added in v0.0.3

func Do[T any](op func() (T, error), retryOptions ...RetryOption) (T, error)

func IsMaxRetriesReached added in v0.0.3

func IsMaxRetriesReached(err error) bool

IsMaxRetriesReached returns true if the cause of the given error is a MaxRetriesReachedError.

func IsTimeout added in v0.0.3

func IsTimeout(err error) bool

IsTimeout returns true if the cause of the given error is a TimeoutError.

Types

type Client

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

func NewClient

func NewClient(serviceToken, workspaceURL string) *Client

func (*Client) CreateAuthorization added in v0.0.3

func (c *Client) CreateAuthorization(ctx context.Context, aName, description, permissions, resourceName string) (*CreateAuthorizationResponse, error)

Authorizations

func (*Client) CreateResource

func (c *Client) CreateResource(ctx context.Context, name, rType string, yamlRConfig []byte) (*CreateResourceResponse, error)

Resources / Integrations

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, sessionName, resourceName, authorizationName, clusterName, ttl, sessionType string, users []string) (*CreateSessionResponse, error)

Sessions

func (*Client) DeleteAuthorization added in v0.0.3

func (c *Client) DeleteAuthorization(ctx context.Context, authID string) (bool, error)

func (*Client) DeleteResource

func (c *Client) DeleteResource(resourceID, resourceName string) (bool, error)

func (*Client) DeleteSession

func (c *Client) DeleteSession(sessionID string) (bool, error)

func (*Client) ReadAuthorization added in v0.0.3

func (c *Client) ReadAuthorization(authID string, waitForStatus bool) (any, error)

func (*Client) ReadSession

func (c *Client) ReadSession(sessionID string, waitForStatus bool) (map[string]interface{}, error)

waitForStatus: if true, will wait for session to be active/fail before returning

func (*Client) UpdateAuthorization added in v0.0.3

func (c *Client) UpdateAuthorization(ctx context.Context, authID, newName, newDescription string) (*UpdateAuthorizationResponse, error)

func (*Client) UpdateResource

func (c *Client) UpdateResource(resourceID string, rType string, yamlRConfig []byte) (*UpdateResourceResponse, error)

func (*Client) UpdateSession

func (c *Client) UpdateSession(sessionID, sessionName, resourceName, authorizationName, clusterName, ttl, sessionType string, users []string) (*UpdateSessionResponse, error)

type CreateAuthorizationRequest added in v0.0.3

type CreateAuthorizationRequest struct {
	AuthorizationName string `json:"name"`
	Resource          string `json:"resource"`
	Description       string `json:"description"`
	Permissions       string `json:"permissions"`
}

Authorizations

type CreateAuthorizationResponse added in v0.0.3

type CreateAuthorizationResponse struct {
	ID string `json:"id"`
}

type CreateResourceRequest

type CreateResourceRequest struct {
	IntegrationType string `json:"integrationType"`
	Name            string `json:"name"`
	Configuration   string `json:"config"`
}

type CreateResourceResponse

type CreateResourceResponse struct {
	ID string `json:"id"`
}

type CreateSessionRequest

type CreateSessionRequest struct {
	SessionName       string `json:"sessionName"`
	ResourceName      string `json:"resourceName"`
	ClusterName       string `json:"clusterName"`
	AuthorizationName string `json:"authorizationName"`
	SessionTTL        string `json:"sessionTTL"`
	SessionType       string `json:"sessionType"`
	// List of user emails to add to the endpoint
	SessionUsers []string `json:"sessionUsers"`
}

sessions

type CreateSessionResponse

type CreateSessionResponse struct {
	ID string `json:"id"`
}

type RetryOption added in v0.0.3

type RetryOption func(options *retryOptions)

Option to dictate behaviour of retry validator

func AfterRetryLimit added in v0.0.3

func AfterRetryLimit(afterRetryLimit func(err error)) RetryOption

AfterRetryLimit is called after a retry limit is reached and can be used e.g. to emit events.

func RetryChecker added in v0.0.3

func RetryChecker(checker func(result any, err error) bool) RetryOption

RetryChecker defines whether the given error is an error that can be retried.

func RetryLimit added in v0.0.3

func RetryLimit(tries int) RetryOption

RetryLimit specifies the maximum number of times op will be called by Do().

func RetryResultChecker added in v0.0.3

func RetryResultChecker(resultChecker func(result any) bool) RetryOption

func Sleep added in v0.0.3

func Sleep(d time.Duration) RetryOption

func Timeout added in v0.0.3

func Timeout(d time.Duration) RetryOption

Timeout specifies the maximum time that should be used before aborting the retry loop. Note that this does not abort the operation in progress.

type UpdateAuthorizationRequest added in v0.0.3

type UpdateAuthorizationRequest struct {
	AuthorizationName        string `json:"name"`
	AuthorizationDescription string `json:"description"`
}

type UpdateAuthorizationResponse added in v0.0.3

type UpdateAuthorizationResponse struct {
	ID string `json:"id"`
}

type UpdateResourceRequest

type UpdateResourceRequest struct {
	IntegrationType string `json:"integrationType"`
	Configuration   string `json:"config"`
}

type UpdateResourceResponse

type UpdateResourceResponse struct {
	ID string `json:"id"`
}

type UpdateSessionRequest

type UpdateSessionRequest = CreateSessionRequest

type UpdateSessionResponse

type UpdateSessionResponse struct {
	ID string `json:"id"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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