sdkservices

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: Apache-2.0 Imports: 10 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 DBServices added in v0.8.4

type DBServices interface {
	Builds() Builds
	Connections() Connections
	Deployments() Deployments
	Events() Events
	Integrations() Integrations
	Orgs() Orgs
	Projects() Projects
	Sessions() Sessions
	Triggers() Triggers
	Users() Users
	Vars() Vars
}

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
	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 DispatchFunc added in v0.12.1

type DispatchFunc func(ctx context.Context, event sdktypes.Event, opts *DispatchOptions) (sdktypes.EventID, error)

type DispatchOptions

type DispatchOptions struct {
	// 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 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)
}

type GetLogResults added in v0.8.0

type GetLogResults struct {
	Log sdktypes.SessionLog
	sdktypes.PaginationResult
}

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) (sdktypes.Integration, error)
	GetByName(ctx context.Context, name sdktypes.Symbol) (sdktypes.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)

	Attach(ctx context.Context, id sdktypes.IntegrationID) (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 {
	ProjectID sdktypes.ProjectID `json:"project_id"`
	Limit     uint32             `json:"limit"`
}

type ListConnectionsFilter

type ListConnectionsFilter struct {
	IntegrationID sdktypes.IntegrationID
	OrgID         sdktypes.OrgID
	ProjectID     sdktypes.ProjectID
	StatusCode    sdktypes.StatusCode
}

func (ListConnectionsFilter) AnyIDSpecified added in v0.12.1

func (f ListConnectionsFilter) AnyIDSpecified() bool

type ListDeploymentsFilter

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

func (ListDeploymentsFilter) AnyIDSpecified added in v0.12.1

func (f ListDeploymentsFilter) AnyIDSpecified() bool

type ListEventsFilter

type ListEventsFilter struct {
	OrgID             sdktypes.OrgID
	ProjectID         sdktypes.ProjectID
	IntegrationID     sdktypes.IntegrationID
	DestinationID     sdktypes.EventDestinationID
	EventType         string
	Limit             int
	CreatedAfter      *time.Time
	MinSequenceNumber uint64
	Order             ListOrder
}

func (ListEventsFilter) AnyIDSpecified added in v0.12.1

func (f ListEventsFilter) AnyIDSpecified() bool

type ListOrder added in v0.6.0

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

type ListSessionLogRecordsFilter added in v0.8.0

type ListSessionLogRecordsFilter struct {
	SessionID sdktypes.SessionID
	Types     sdktypes.SessionLogRecordType // bitmask
	sdktypes.PaginationRequest
}

type ListSessionResult added in v0.4.6

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

type ListSessionsFilter

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

	sdktypes.PaginationRequest
}

func (ListSessionsFilter) AnyIDSpecified added in v0.12.1

func (f ListSessionsFilter) AnyIDSpecified() bool

type ListTriggersFilter added in v0.2.0

type ListTriggersFilter struct {
	OrgID        sdktypes.OrgID
	ProjectID    sdktypes.ProjectID
	ConnectionID sdktypes.ConnectionID
	SourceType   sdktypes.TriggerSourceType
}

func (ListTriggersFilter) AnyIDSpecified added in v0.12.1

func (f ListTriggersFilter) AnyIDSpecified() bool

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, integration string, cid sdktypes.ConnectionID, origin string) (string, error)
	Exchange(ctx context.Context, integration string, cid sdktypes.ConnectionID, code string) (*oauth2.Token, error)
}

OAuth is a generic implementation of 3-legged OAuth 2.0 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 Orgs added in v0.12.1

type Orgs interface {
	Create(ctx context.Context, org sdktypes.Org) (sdktypes.OrgID, error)
	GetByID(ctx context.Context, id sdktypes.OrgID) (sdktypes.Org, error)
	Update(ctx context.Context, org sdktypes.Org) error
	ListMembers(ctx context.Context, oid sdktypes.OrgID) ([]sdktypes.UserID, error)
	AddMember(ctx context.Context, oid sdktypes.OrgID, uid sdktypes.UserID) error
	RemoveMember(ctx context.Context, oid sdktypes.OrgID, uid sdktypes.UserID) error
	IsMember(ctx context.Context, oid sdktypes.OrgID, uid sdktypes.UserID) (bool, error)
	GetOrgsForUser(ctx context.Context, uid sdktypes.UserID) ([]sdktypes.Org, error)
}

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, oid sdktypes.OrgID, name sdktypes.Symbol) (sdktypes.Project, error)
	List(ctx context.Context, oid sdktypes.OrgID) ([]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)
	Export(ctx context.Context, projectID sdktypes.ProjectID) ([]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,
		sid sdktypes.SessionID,
		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,
		sid sdktypes.SessionID,
		path string,
		build *sdkbuildfile.BuildFile,
		globals map[string]sdktypes.Value,
		cbs *RunCallbacks,
	) (Run, error)
}

type Services

type Services interface {
	DBServices

	Auth() Auth
	Dispatcher() Dispatcher
	OAuth() OAuth
	Runtimes() Runtimes
	Store() Store
}

type ServicesStruct added in v0.9.0

type ServicesStruct struct {
	fx.In // this can also be used using uber's Fx.

	Auth_         Auth         `optional:"true"`
	Builds_       Builds       `optional:"true"`
	Connections_  Connections  `optional:"true"`
	Deployments_  Deployments  `optional:"true"`
	Dispatcher_   Dispatcher   `optional:"true"`
	Events_       Events       `optional:"true"`
	Integrations_ Integrations `optional:"true"`
	OAuth_        OAuth        `optional:"true"`
	Orgs_         Orgs         `optional:"true"`
	Projects_     Projects     `optional:"true"`
	Runtimes_     Runtimes     `optional:"true"`
	Sessions_     Sessions     `optional:"true"`
	Store_        Store        `optional:"true"`
	Triggers_     Triggers     `optional:"true"`
	Users_        Users        `optional:"true"`
	Vars_         Vars         `optional:"true"`
}

func (*ServicesStruct) Auth added in v0.9.0

func (s *ServicesStruct) Auth() Auth

func (*ServicesStruct) Builds added in v0.9.0

func (s *ServicesStruct) Builds() Builds

func (*ServicesStruct) Connections added in v0.9.0

func (s *ServicesStruct) Connections() Connections

func (*ServicesStruct) Deployments added in v0.9.0

func (s *ServicesStruct) Deployments() Deployments

func (*ServicesStruct) Dispatcher added in v0.9.0

func (s *ServicesStruct) Dispatcher() Dispatcher

func (*ServicesStruct) Events added in v0.9.0

func (s *ServicesStruct) Events() Events

func (*ServicesStruct) Integrations added in v0.9.0

func (s *ServicesStruct) Integrations() Integrations

func (*ServicesStruct) OAuth added in v0.9.0

func (s *ServicesStruct) OAuth() OAuth

func (*ServicesStruct) Orgs added in v0.12.1

func (s *ServicesStruct) Orgs() Orgs

func (*ServicesStruct) Projects added in v0.9.0

func (s *ServicesStruct) Projects() Projects

func (*ServicesStruct) Runtimes added in v0.9.0

func (s *ServicesStruct) Runtimes() Runtimes

func (*ServicesStruct) Sessions added in v0.9.0

func (s *ServicesStruct) Sessions() Sessions

func (*ServicesStruct) Store added in v0.9.0

func (s *ServicesStruct) Store() Store

func (*ServicesStruct) Triggers added in v0.9.0

func (s *ServicesStruct) Triggers() Triggers

func (*ServicesStruct) Users added in v0.12.1

func (s *ServicesStruct) Users() Users

func (*ServicesStruct) Vars added in v0.9.0

func (s *ServicesStruct) 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, filter ListSessionLogRecordsFilter) (*GetLogResults, error)
	Delete(ctx context.Context, sessionID sdktypes.SessionID) error
}

type Store

type Store interface {
	Get(ctx context.Context, pid sdktypes.ProjectID, keys []string) (map[string]sdktypes.Value, error)
	List(ctx context.Context, pid 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 Users added in v0.12.1

type Users interface {
	Create(ctx context.Context, user sdktypes.User) (sdktypes.UserID, error)

	Update(ctx context.Context, user sdktypes.User) error

	// at least one of the arguments must be non-zero.
	Get(ctx context.Context, id sdktypes.UserID, email string) (sdktypes.User, 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)
	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