api

package
v0.47.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 18 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const BearerProtocol = "bearer"

BearerProtocol is the WebSocket subprotocol a browser offers together with its token, as new WebSocket(url, ["bearer", token]); the answer names only "bearer" (DBG-08).

View Source
const (
	CloseTokenExpired = websocket.StatusCode(4401)
)

close codes of the live stream: 4000 plus the HTTP status of the reason, e.g. 4401 when the token expired and the client should reconnect with a new one

View Source
const DefaultLivePingPeriod = 20 * time.Second

DefaultLivePingPeriod keeps a quiet live stream open: the NGINX ingress in front of the engine closes a connection that sends nothing for 60 seconds

Variables

This section is empty.

Functions

func New

func New(controller Controller, pinger Pinger, logger *slog.Logger, settings Settings) http.Handler

New builds the HTTP handler of the API; routes use the pattern routing of net/http.

@title			Automation-Engine API
@version		0.1
@description	Models, deployments and instances of processes and smart services.
@license.name	Apache 2.0
@license.url	http://www.apache.org/licenses/LICENSE-2.0.html
@BasePath		/
@securityDefinitions.apikey	Bearer
@in							header
@name						Authorization
@description				Type "Bearer" followed by a space and JWT token.

Types

type AuthMessage

type AuthMessage struct {
	Type  string `json:"type"`
	Token string `json:"token"`
}

AuthMessage is the first message of a live stream whose client cannot set headers (DBG-08).

type Controller

type Controller interface {
	ListNamespaces(ctx context.Context, token string) ([]model.Namespace, error)
	GetNamespace(ctx context.Context, token string, namespace string) (model.Namespace, error)
	// Validate checks BPMN against the rules of a namespace without storing it (BPMN-18)
	Validate(ctx context.Context, token string, namespace string, xml string) ([]model.Issue, error)
	// Convert rewrites a model written for Camunda 7 without storing it (MIG-04)
	Convert(ctx context.Context, token string, namespace string, xml string) (model.Conversion, error)
	// PutNamespace creates or changes a namespace; admins only (NS-02)
	PutNamespace(ctx context.Context, token string, name string, ns model.Namespace) (model.Namespace, error)
	// DeleteNamespace removes a namespace without resources; admins only
	DeleteNamespace(ctx context.Context, token string, name string) error

	// SetOwner changes the owner of a model, deployment or instance (SEC-11)
	SetOwner(ctx context.Context, token string, namespace string, kind model.Kind, id string, input model.OwnerInput) error

	CreateModel(ctx context.Context, token string, namespace string, input model.ModelInput) (model.Model, error)
	// UpdateModel stores a new version of the model (MOD-05)
	UpdateModel(ctx context.Context, token string, namespace string, id string, input model.ModelInput) (model.Model, error)
	GetModel(ctx context.Context, token string, namespace string, id string) (model.Model, error)
	ListModels(ctx context.Context, token string, namespace string, options model.ModelListOptions) (model.Page[model.Model], error)
	// DeleteModel refuses a model module tasks deploy, unless an admin forces it (SMS-15)
	DeleteModel(ctx context.Context, token string, namespace string, id string, force bool) error
	PublishModel(ctx context.Context, token string, namespace string, id string, input model.PublishInput) (model.Model, error)
	ListModelVersions(ctx context.Context, token string, namespace string, id string, options model.PageOptions) (model.Page[model.ModelVersion], error)
	GetModelVersion(ctx context.Context, token string, namespace string, id string, version int) (model.ModelVersion, error)

	CreateDeployment(ctx context.Context, token string, namespace string, input model.DeploymentInput) (model.Deployment, error)
	// PutDeployment creates a deployment with the given id or updates it with a new version (DEP-04)
	PutDeployment(ctx context.Context, token string, namespace string, id string, input model.DeploymentInput) (model.Deployment, error)
	GetDeployment(ctx context.Context, token string, namespace string, id string) (model.Deployment, error)
	ListDeployments(ctx context.Context, token string, namespace string, options model.DeploymentListOptions) (model.Page[model.Deployment], error)
	DeleteDeployment(ctx context.Context, token string, namespace string, id string) error
	// DeploymentInstanceCount counts the instances of all users on a version; administrators only
	DeploymentInstanceCount(ctx context.Context, token string, namespace string, id string, version int) (model.Count, error)
	// ResourceUsage counts the deployment versions and instances that use a process model, flow
	// or import type (SMS-15)
	ResourceUsage(ctx context.Context, token string, namespace string, kind string, id string) (model.ResourceUsage, error)
	// SetDeploymentDisabled switches a deployment off or on (DEP-12)
	SetDeploymentDisabled(ctx context.Context, token string, namespace string, id string, input model.DisabledInput) (model.Deployment, error)
	ListDeploymentVersions(ctx context.Context, token string, namespace string, id string, options model.PageOptions) (model.Page[model.DeploymentVersion], error)
	GetDeploymentVersion(ctx context.Context, token string, namespace string, id string, version int) (model.DeploymentVersion, error)
	GetDeploymentSource(ctx context.Context, token string, namespace string, id string, version int) (model.ModelVersion, error)
	GetStartParameters(ctx context.Context, token string, namespace string, deploymentId string) ([]model.StartParameter, error)
	DeploymentsUsable(ctx context.Context, token string, namespace string, ids []string) (map[string]bool, error)
	// PrepareDeployment lists start parameters and the selectable devices per element (DEP-01)
	PrepareDeployment(ctx context.Context, token string, namespace string, input model.PrepareInput) (model.PreparedDeployment, error)
	// ListEventDescriptions shows what event workers evaluate for a deployment (DEP-07)
	ListEventDescriptions(ctx context.Context, token string, namespace string, deploymentId string) ([]model.EventDescription, error)
	// ResetRestarts clears the faulty mark of a deployment after a restart loop (INC-04)
	ResetRestarts(ctx context.Context, token string, namespace string, id string) (model.Deployment, error)

	StartInstance(ctx context.Context, token string, namespace string, input model.StartInstanceInput) (model.Instance, error)
	// PutInstance starts an instance with the given id idempotently (RUN-01)
	PutInstance(ctx context.Context, token string, namespace string, id string, input model.StartInstanceInput) (model.Instance, error)
	GetInstance(ctx context.Context, token string, namespace string, id string) (model.Instance, error)
	// UpdateInstanceInfo changes name and description of an instance
	UpdateInstanceInfo(ctx context.Context, token string, namespace string, id string, input model.InstanceInfoInput) (model.Instance, error)
	ListInstances(ctx context.Context, token string, namespace string, options model.InstanceListOptions) (model.Page[model.Instance], error)
	// DeleteInstances removes instances with their history (HIST-03)
	DeleteInstances(ctx context.Context, token string, namespace string, ids []string) error
	StopInstances(ctx context.Context, token string, namespace string, ids []string) error
	RestartInstance(ctx context.Context, token string, namespace string, id string, input model.RestartInput) (model.Instance, error)
	ListRuns(ctx context.Context, token string, namespace string, id string) ([]model.Run, error)
	GetVariables(ctx context.Context, token string, namespace string, id string) ([]model.Variable, error)
	SetVariable(ctx context.Context, token string, namespace string, id string, name string, value any) error
	// TriggerWait triggers the event or timer an element waits for at once (DBG-17)
	TriggerWait(ctx context.Context, token string, namespace string, id string, elementId string, input model.TriggerInput) error
	ListActivities(ctx context.Context, token string, namespace string, id string, options model.ActivityListOptions) (model.ActivityPage, error)
	ListElementStats(ctx context.Context, token string, namespace string, id string, run int) ([]model.ElementStats, error)
	GetVariable(ctx context.Context, token string, namespace string, id string, name string, elementId string) (model.Variable, error)

	DebugState(ctx context.Context, token string, namespace string, id string, options model.DebugOptions) (model.DebugState, error)
	Watch(ctx context.Context, token string, namespace string, id string, options model.WatchOptions) (<-chan model.DebugMessage, error)
	HistoryState(ctx context.Context, token string, namespace string, id string, options model.HistoryOptions) (model.DebugState, error)
	EventEvaluations(ctx context.Context, token string, namespace string, id string, options model.EventReconstructionOptions) (model.EventReconstruction, error)
	HistoryVariable(ctx context.Context, token string, namespace string, id string, name string, elementId string, options model.HistoryOptions) (model.HistoryVariable, error)

	UpdateParameters(ctx context.Context, token string, namespace string, id string, input model.ParametersInput) (model.Instance, error)
	DeleteVariable(ctx context.Context, token string, namespace string, id string, name string) error
	DeploymentParameters(ctx context.Context, token string, namespace string, id string) ([]model.ParameterDescription, error)
	MaintenanceParameters(ctx context.Context, token string, namespace string, id string, procedure string) ([]model.ParameterDescription, error)
	ListMaintenanceProcedures(ctx context.Context, token string, namespace string, id string) ([]model.MaintenanceProcedure, error)
	StartMaintenance(ctx context.Context, token string, namespace string, id string, procedure string, input model.MaintenanceStartInput) (model.Instance, error)

	ListModules(ctx context.Context, token string, namespace string, options model.ModuleListOptions) (model.Page[model.Module], error)
	GetModule(ctx context.Context, token string, namespace string, id string) (model.Module, error)
	DeleteModule(ctx context.Context, token string, namespace string, id string) error

	ListIncidents(ctx context.Context, token string, namespace string, options model.IncidentListOptions) (model.Page[model.Incident], error)

	CorrelateMessage(ctx context.Context, token string, input model.MessageInput) (model.CorrelationResult, error)

	// schedules start instances of deployments by cron (RUN-07)
	ListSchedules(ctx context.Context, token string, namespace string, options model.ScheduleListOptions) (model.Page[model.Schedule], error)
	GetSchedule(ctx context.Context, token string, namespace string, id string) (model.Schedule, error)
	CreateSchedule(ctx context.Context, token string, namespace string, input model.ScheduleInput) (model.Schedule, error)
	UpdateSchedule(ctx context.Context, token string, namespace string, id string, input model.ScheduleInput) (model.Schedule, error)
	DeleteSchedule(ctx context.Context, token string, namespace string, id string) error

	// the process-io store of the caller (IO-02)
	ListIoValues(ctx context.Context, token string, options model.IoListOptions) (model.Page[model.IoValue], error)
	GetIoValue(ctx context.Context, token string, key string) (model.IoValue, error)
	SetIoValue(ctx context.Context, token string, key string, input model.IoValueInput) error
	DeleteIoValue(ctx context.Context, token string, key string) error
	IoBulk(ctx context.Context, token string, bulk model.IoBulk) ([]model.IoValue, error)

	// the gateways the cloud synchronises with (SYNC-12, SYNC-13)
	ListNetworks(ctx context.Context, token string) ([]model.Network, error)
	GetNetwork(ctx context.Context, token string, networkId string) (model.Network, error)
	// ImportNetwork takes over the deployments of a gateway from its export; admins only (SNRGY-5066)
	ImportNetwork(ctx context.Context, token string, networkId string, doc model.GatewayExport, options model.NetworkImportOptions) (model.NetworkImport, error)

	// ListBlockedScripts lists the scripts that ended the engine; admins only (EXPR-03)
	ListBlockedScripts(ctx context.Context, token string) ([]model.BlockedScript, error)
	// UnblockScript removes a script from the blocklist; admins only (EXPR-03)
	UnblockScript(ctx context.Context, token string, fingerprint string) error

	// GetUserDependents is the dry run of DeleteUser; admins only (SEC-14)
	GetUserDependents(ctx context.Context, token string, userId string) (model.UserDependents, error)
	// DeleteUser removes everything a user owns; admins only (SEC-08, SEC-13)
	DeleteUser(ctx context.Context, token string, userId string) error
	GetUserSettings(ctx context.Context, token string, userId string) (model.UserSettings, error)
	// SetUserSettings sets limits of a user; admins only (HIST-04)
	SetUserSettings(ctx context.Context, token string, userId string, settings model.UserSettings) (model.UserSettings, error)
}

Controller is the complete API of the engine. The server implements it, the HTTP client and the in-process test client implement it as well (CLI-08, CLI-09). Every call takes the user token (CLI-10).

type Cors

type Cors struct {
	// allowed origins, e.g. https://ui.example.org; "*" allows every origin
	Origins []string
	// request headers a browser may send; "*" does not cover Authorization
	Headers []string
}

Cors are the CORS headers for browser applications that call the engine directly. In the platform Kong sets them, so without origins the API sets none.

type Pinger

type Pinger interface {
	Ping(ctx context.Context) error
}

Pinger reports whether the service is ready, e.g. whether the database is reachable.

type Settings

type Settings struct {
	// verifies the signature of a token; set, the live stream checks its token with it, whether it
	// comes in the header or as first message, which does not pass Kong (DBG-08). Other requests
	// are verified by the controller, and only with verify_tokens.
	VerifyToken func(token string) error
	// interval of pings on the live stream; 0 is DefaultLivePingPeriod
	LivePingPeriod time.Duration
	// the engine runs on a gateway: the API is read-only and needs no token (FOG, M6)
	Gateway bool
	// serves the old APIs below /deprecated/ (API-02); nil serves none
	Deprecated http.Handler
	// CORS headers; without origins none
	Cors Cors
}

Settings of the API that depend on the deployment.

type ValidateInput

type ValidateInput struct {
	Xml string `json:"xml"`
}

ValidateInput is the body of the validate endpoint.

Jump to

Keyboard shortcuts

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