sdkservices

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builds

type Builds interface {
	Get(ctx context.Context, id sdktypes.BuildID) (sdktypes.Build, error)
	List(ctx context.Context, filter ListBuildsFilter) ([]sdktypes.Build, error)
	Download(ctx context.Context, id sdktypes.BuildID) (io.ReadCloser, error)
	Save(ctx context.Context, build sdktypes.Build, data []byte) (sdktypes.BuildID, error)
	Delete(ctx context.Context, id sdktypes.BuildID) error
	Describe(ctx context.Context, id sdktypes.BuildID) (*sdkbuildfile.BuildFile, error)
}

type Deployments

type Deployments interface {
	Create(ctx context.Context, deployment sdktypes.Deployment) (sdktypes.DeploymentID, error)
	Activate(ctx context.Context, deploymentID sdktypes.DeploymentID) error
	Deactivate(ctx context.Context, deploymentID sdktypes.DeploymentID) error
	Drain(ctx context.Context, deploymentID sdktypes.DeploymentID) error
	Get(ctx context.Context, id sdktypes.DeploymentID) (sdktypes.Deployment, error)
	Test(ctx context.Context, deploymentID sdktypes.DeploymentID) error
	List(ctx context.Context, filter ListDeploymentsFilter) ([]sdktypes.Deployment, error)
	Delete(ctx context.Context, id sdktypes.DeploymentID) error
}

type DispatchOptions

type DispatchOptions struct {
	// If set, dispatch only to deployments in this environment.
	EnvID sdktypes.EnvID

	// If set, dispatch only to this specific deployment.
	DeploymentID sdktypes.DeploymentID
}

type Dispatcher

type Dispatcher interface {
	Dispatch(ctx context.Context, event sdktypes.Event, opts *DispatchOptions) (sdktypes.EventID, error)
	Redispatch(ctx context.Context, eventID sdktypes.EventID, opts *DispatchOptions) (sdktypes.EventID, error)
}

type Envs

type Envs interface {
	List(ctx context.Context, projectID sdktypes.ProjectID) ([]sdktypes.Env, error)
	Create(ctx context.Context, env sdktypes.Env) (sdktypes.EnvID, error)
	GetByID(ctx context.Context, envID sdktypes.EnvID) (sdktypes.Env, error)
	GetByName(ctx context.Context, projectID sdktypes.ProjectID, name sdktypes.Symbol) (sdktypes.Env, error)
	Remove(ctx context.Context, envID sdktypes.EnvID) error
	Update(ctx context.Context, env sdktypes.Env) error

	SetVar(ctx context.Context, envVar sdktypes.EnvVar) error
	RemoveVar(ctx context.Context, envID sdktypes.EnvID, name sdktypes.Symbol) error
	// If names is empty, all vars are returned.
	GetVars(ctx context.Context, names []sdktypes.Symbol, envID sdktypes.EnvID) ([]sdktypes.EnvVar, error)
	RevealVar(ctx context.Context, envID sdktypes.EnvID, varName sdktypes.Symbol) (string, error)
}

type Events

type Events interface {
	Save(ctx context.Context, event sdktypes.Event) (sdktypes.EventID, error)
	Get(ctx context.Context, eventID sdktypes.EventID) (sdktypes.Event, error)
	List(ctx context.Context, filter ListEventsFilter) ([]sdktypes.Event, error)
	AddEventRecord(context.Context, sdktypes.EventRecord) error
	ListEventRecords(context.Context, ListEventRecordsFilter) ([]sdktypes.EventRecord, error)
}

type Integration

type Integration interface {
	// Get returns the configuration details of this integration and the
	// external service that it wraps.
	Get() sdktypes.Integration

	Configure(ctx context.Context, config string) (map[string]sdktypes.Value, error)

	sdkexecutor.Caller
}

Integration is implemented for each external service, to let the autokitteh server interact with it.

type Integrations

type Integrations interface {
	// Get returns the instance of an integration which has already been registered
	// in the autokitteh server, and is available for usage by runtime connections.
	Get(ctx context.Context, id sdktypes.IntegrationID) (Integration, error)

	// List returns an enumeration - with optional filtering - of all
	// the integrations which have been registered in the autokitteh
	// server, and are available for usage by runtime connections.
	// TODO: Add an optional tag-search-term filter argument.
	List(ctx context.Context, nameSubstring string) ([]sdktypes.Integration, error)
}

Integrations is implemented by the autokitteh core, to manage integrations of external services within a running autokitteh server.

type ListBuildsFilter

type ListBuildsFilter struct {
	Limit uint32
}

type ListConnectionsFilter

type ListConnectionsFilter struct {
	IntegrationID    sdktypes.IntegrationID
	IntegrationToken string
	ProjectID        sdktypes.ProjectID
}

type ListDeploymentsFilter

type ListDeploymentsFilter struct {
	EnvID               sdktypes.EnvID
	BuildID             sdktypes.BuildID
	State               sdktypes.DeploymentState
	Limit               uint32
	IncludeSessionStats bool
}

type ListEventRecordsFilter

type ListEventRecordsFilter struct {
	EventID sdktypes.EventID
}

type ListEventsFilter

type ListEventsFilter struct {
	IntegrationID     sdktypes.IntegrationID
	IntegrationToken  string
	OriginalID        string
	EventType         string
	Limit             int
	CreatedAfter      *time.Time
	MinSequenceNumber uint64
}

type ListIntegrationsFilter

type ListIntegrationsFilter struct {
	NameSubstring string
}

type ListSessionsFilter

type ListSessionsFilter struct {
	DeploymentID sdktypes.DeploymentID
	EnvID        sdktypes.EnvID
	EventID      sdktypes.EventID
	StateType    sdktypes.SessionStateType
	CountOnly    bool
}

type ListTriggersFilter added in v0.2.0

type ListTriggersFilter struct {
	ProjectID    sdktypes.ProjectID
	EnvID        sdktypes.EnvID
	ConnectionID sdktypes.ConnectionID
}

type NewRunIDFunc

type NewRunIDFunc = func() sdktypes.RunID

type OAuth

type OAuth interface {
	Register(ctx context.Context, id string, cfg *oauth2.Config, opts map[string]string) error
	Get(ctx context.Context, id string) (*oauth2.Config, map[string]string, error)
	StartFlow(ctx context.Context, id string) (string, error)
	Exchange(ctx context.Context, id, state, code string) (*oauth2.Token, error)
}

OAuth is a generic implementation of 3-legged OAuth v2 flows, reusable by OAuth-based integrations and autokitteh user authentication. It assumes that the autokitteh server has a public address for callbacks, which allows callers of this service not to care about this requirement.

type Projects

type Projects interface {
	Create(ctx context.Context, project sdktypes.Project) (sdktypes.ProjectID, error)
	Delete(ctx context.Context, projectID sdktypes.ProjectID) error
	Update(ctx context.Context, project sdktypes.Project) error
	GetByID(ctx context.Context, projectID sdktypes.ProjectID) (sdktypes.Project, error)
	GetByName(ctx context.Context, name sdktypes.Symbol) (sdktypes.Project, error)
	List(ctx context.Context) ([]sdktypes.Project, error)
	Build(ctx context.Context, projectID sdktypes.ProjectID) (sdktypes.BuildID, error)
	SetResources(ctx context.Context, projectID sdktypes.ProjectID, resources map[string][]byte) error
	DownloadResources(ctx context.Context, projectID sdktypes.ProjectID) (map[string][]byte, error)
}

type Run

type Run interface {
	ID() sdktypes.RunID

	Close()

	sdkexecutor.Executor
}

type RunCallFunc

type RunCallFunc = func(ctx context.Context, rid sdktypes.RunID, v sdktypes.Value, args []sdktypes.Value, kwargs map[string]sdktypes.Value) (sdktypes.Value, error)

type RunCallbacks

type RunCallbacks struct {
	// Returns sdktypes.ProgramErrorAsError if not internal error.
	Load RunLoadFunc

	// Returns sdktypes.ProgramErrorAsError if not internal error.
	Call RunCallFunc

	Print RunPrintFunc

	NewRunID NewRunIDFunc
}

func (*RunCallbacks) SafeCall

func (rc *RunCallbacks) SafeCall(ctx context.Context, rid sdktypes.RunID, v sdktypes.Value, args []sdktypes.Value, kwargs map[string]sdktypes.Value) (sdktypes.Value, error)

func (*RunCallbacks) SafeLoad

func (rc *RunCallbacks) SafeLoad(ctx context.Context, rid sdktypes.RunID, path string) (map[string]sdktypes.Value, error)

func (*RunCallbacks) SafeNewRunID

func (rc *RunCallbacks) SafeNewRunID() sdktypes.RunID

func (*RunCallbacks) SafePrint

func (rc *RunCallbacks) SafePrint(ctx context.Context, rid sdktypes.RunID, text string)

type RunLoadFunc

type RunLoadFunc = func(ctx context.Context, rid sdktypes.RunID, path string) (map[string]sdktypes.Value, error)

type RunPrintFunc

type RunPrintFunc = func(ctx context.Context, rid sdktypes.RunID, text string)

type Runtime

type Runtime interface {
	Get() sdktypes.Runtime

	// Returns sdktypes.ProgramErrorAsError if not internal error.
	Build(ctx context.Context, fs fs.FS, path string, symbols []sdktypes.Symbol) (sdktypes.BuildArtifact, error)

	// Returns sdktypes.ProgramErrorAsError if not internal error.
	Run(
		ctx context.Context,
		rid sdktypes.RunID,
		path string,
		compiled map[string][]byte,
		values map[string]sdktypes.Value,
		cbs *RunCallbacks,
	) (Run, error)
}

type Runtimes

type Runtimes interface {
	List(ctx context.Context) ([]sdktypes.Runtime, error)
	New(ctx context.Context, name sdktypes.Symbol) (Runtime, error)

	Build(ctx context.Context, fs fs.FS, symbols []sdktypes.Symbol, memo map[string]string) (*sdkbuildfile.BuildFile, error)

	Run(
		ctx context.Context,
		rid sdktypes.RunID,
		path string,
		build *sdkbuildfile.BuildFile,
		globals map[string]sdktypes.Value,
		cbs *RunCallbacks,
	) (Run, error)
}

type Secrets

type Secrets interface {
	// Create generates a new token to represent a connection's specified
	// key-value data, and associates them bidirectionally. If the same
	// request is sent N times, this method returns N different tokens.
	Create(ctx context.Context, scope string, data map[string]string, key string) (token string, err error)
	// Get retrieves a connection's key-value data based on the given token.
	// If the token isn’t found then we return an error.
	Get(ctx context.Context, scope string, token string) (data map[string]string, err error)
	// List enumerates all the tokens (0 or more) that are associated with a given
	// connection identifier. This enables autokitteh to dispatch/fan-out asynchronous
	// events that it receives from integrations through all the relevant connections.
	List(ctx context.Context, scope string, key string) (tokens []string, err error)
}

SecretsService is a simple API for managing autokitteh user secrets. So far, this is limited to connections (managed by integrations).

type Services

type Services interface {
	Builds() Builds
	Connections() Connections
	Deployments() Deployments
	Dispatcher() Dispatcher
	Envs() Envs
	Events() Events
	Integrations() Integrations
	OAuth() OAuth
	Projects() Projects
	Runtimes() Runtimes
	Secrets() Secrets
	Sessions() Sessions
	Store() Store
	Triggers() Triggers
}

type Sessions

type Sessions interface {
	Start(ctx context.Context, session sdktypes.Session) (sdktypes.SessionID, error)
	Stop(ctx context.Context, sessionID sdktypes.SessionID, reason string, force bool) error
	List(ctx context.Context, filter ListSessionsFilter) ([]sdktypes.Session, int, error)
	Get(ctx context.Context, sessionID sdktypes.SessionID) (sdktypes.Session, error)
	GetLog(ctx context.Context, sessionID sdktypes.SessionID) (sdktypes.SessionLog, error)
	Delete(ctx context.Context, sessionID sdktypes.SessionID) error
}

type Store

type Store interface {
	Get(ctx context.Context, envID sdktypes.EnvID, projectID sdktypes.ProjectID, keys []string) (map[string]sdktypes.Value, error)
	List(ctx context.Context, envID sdktypes.EnvID, projectID sdktypes.ProjectID) ([]string, error)
}

type Triggers added in v0.2.0

type Triggers interface {
	Create(ctx context.Context, trigger sdktypes.Trigger) (sdktypes.TriggerID, error)
	Update(ctx context.Context, trigger sdktypes.Trigger) error
	Delete(ctx context.Context, triggerID sdktypes.TriggerID) error
	Get(ctx context.Context, triggerID sdktypes.TriggerID) (sdktypes.Trigger, error)
	List(ctx context.Context, filter ListTriggersFilter) ([]sdktypes.Trigger, error)
}

Jump to

Keyboard shortcuts

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