sdkservices

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 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 Auth added in v0.5.0

type Auth interface {
	WhoAmI(ctx context.Context) (sdktypes.User, error)
	CreateToken(ctx context.Context) (string, error)
}

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. Can be either an env ID or full path (project/env).
	Env string

	// 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
}

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 returns events without their data.
	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, cid sdktypes.ConnectionID) (vs map[string]sdktypes.Value, config map[string]string, err error)

	TestConnection(ctx context.Context, cid sdktypes.ConnectionID) (sdktypes.Status, error)

	GetConnectionStatus(ctx context.Context, cid sdktypes.ConnectionID) (sdktypes.Status, error)

	GetConnectionConfig(ctx context.Context, cid sdktypes.ConnectionID) (map[string]string, 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.
	GetByID(ctx context.Context, id sdktypes.IntegrationID) (Integration, error)
	GetByName(ctx context.Context, name sdktypes.Symbol) (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
	ProjectID     sdktypes.ProjectID
	StatusCode    sdktypes.StatusCode
}

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
	ConnectionID      sdktypes.ConnectionID
	EventType         string
	Limit             int
	CreatedAfter      *time.Time
	MinSequenceNumber uint64
	Order             ListOrder
}

type ListOrder added in v0.6.0

type ListOrder string
const (
	ListOrderAscending  ListOrder = "ASC"
	ListOrderDescending ListOrder = "DESC"
)

type ListSessionResult added in v0.4.6

type ListSessionResult struct {
	Sessions []sdktypes.Session
	sdktypes.PaginationResult
}

type ListSessionsFilter

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

	sdktypes.PaginationRequest
}

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, cid sdktypes.ConnectionID) (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 Scheduler added in v0.6.4

type Scheduler interface {
	Create(ctx context.Context, scheduleID string, schedule string, triggerID sdktypes.TriggerID) error
	Delete(ctx context.Context, scheduleID string) error
	Update(ctx context.Context, scheduleID string, schedule string) error
}

type Services

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

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 returns sessions without their data.
	List(ctx context.Context, filter ListSessionsFilter) (ListSessionResult, 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)
}

type Vars added in v0.5.0

type Vars interface {
	Set(ctx context.Context, v ...sdktypes.Var) error
	Delete(ctx context.Context, sid sdktypes.VarScopeID, names ...sdktypes.Symbol) error
	Get(ctx context.Context, sid sdktypes.VarScopeID, names ...sdktypes.Symbol) (sdktypes.Vars, error)
	Reveal(ctx context.Context, sid sdktypes.VarScopeID, names ...sdktypes.Symbol) (sdktypes.Vars, error)
	FindConnectionIDs(ctx context.Context, iid sdktypes.IntegrationID, name sdktypes.Symbol, value string) ([]sdktypes.ConnectionID, error)
}

Jump to

Keyboard shortcuts

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