client

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: 29 Imported by: 2 modules, 2 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

Overview

Package client is the Go client of the Automation-Engine API (CLI-01 to CLI-10). It uses the types of the server, so that fields cannot get lost between both sides.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T any](list func(page model.PageOptions) (model.Page[T], error)) iter.Seq2[T, error]

All iterates over all items of a paged list by requesting page after page (CLI-04):

for m, err := range client.All(func(page model.PageOptions) (model.Page[model.Model], error) {
	return c.ListModels(ctx, token, "processes", model.ModelListOptions{PageOptions: page})
}) { ... }

Iteration stops after the first error, which is yielded with a zero item.

func NewTestServer

func NewTestServer(ctx context.Context, configure func(config *configuration.Config, deps *server.Dependencies)) (*server.Server, error)

NewTestServer starts the engine of NewTestClient and returns the server, e.g. to serve its Handler over HTTP or to run a background job at once. configure, if given, changes the configuration and the dependencies before the start. The server stops when ctx is done.

func NewTokenExchange

func NewTokenExchange(endpoint string, clientId string, clientSecret string) *auth.TokenExchange

NewTokenExchange returns tokens of other users through Keycloak token exchange, for services that act on behalf of a user (CLI-10).

func NewTokenProvider

func NewTokenProvider(endpoint string, clientId string, clientSecret string) func() (string, error)

NewTokenProvider returns tokens of a Keycloak client through client credentials, refreshed before they expire (CLI-10). endpoint is the Keycloak base URL, e.g. http://keycloak:8080.

func TestDependencies

func TestDependencies(ctx context.Context) (server.Dependencies, error)

TestDependencies run permissions-v2 in the process with an admin token it accepts, and with the topics devices and device-groups that selections are checked against.

func TestHubOwners added in v0.16.0

func TestHubOwners(owners map[string]string) devicerepository.Interface

TestHubOwners stands in for device-repository as the source of the owners of networks, by network id (FOG-11): it answers ReadHub, any other method of the client is not expected.

func TestToken

func TestToken(user string, roles ...string) string

TestToken creates an unsigned token for user with the given realm roles, e.g. "admin". It works with servers that do not verify signatures, like the test client.

Types

type Client

type Client interface {
	api.Controller
}

Client is the complete API; New returns the HTTP implementation, NewTestClient one that runs the engine in the process.

type ClientImpl

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

func New

func New(baseUrl string) *ClientImpl

func (*ClientImpl) Convert

func (this *ClientImpl) Convert(ctx context.Context, token string, namespace string, xml string) (result model.Conversion, err error)

func (*ClientImpl) CorrelateMessage

func (this *ClientImpl) CorrelateMessage(ctx context.Context, token string, input model.MessageInput) (result model.CorrelationResult, err error)

func (*ClientImpl) CreateDeployment

func (this *ClientImpl) CreateDeployment(ctx context.Context, token string, namespace string, input model.DeploymentInput) (result model.Deployment, err error)

func (*ClientImpl) CreateModel

func (this *ClientImpl) CreateModel(ctx context.Context, token string, namespace string, input model.ModelInput) (result model.Model, err error)

func (*ClientImpl) CreateSchedule

func (this *ClientImpl) CreateSchedule(ctx context.Context, token string, namespace string, input model.ScheduleInput) (result model.Schedule, err error)

func (*ClientImpl) DebugState

func (this *ClientImpl) DebugState(ctx context.Context, token string, namespace string, id string, options model.DebugOptions) (result model.DebugState, err error)

func (*ClientImpl) DeleteDeployment

func (this *ClientImpl) DeleteDeployment(ctx context.Context, token string, namespace string, id string) error

func (*ClientImpl) DeleteInstances

func (this *ClientImpl) DeleteInstances(ctx context.Context, token string, namespace string, ids []string) error

func (*ClientImpl) DeleteIoValue

func (this *ClientImpl) DeleteIoValue(ctx context.Context, token string, key string) error

func (*ClientImpl) DeleteModel

func (this *ClientImpl) DeleteModel(ctx context.Context, token string, namespace string, id string, force bool) error

func (*ClientImpl) DeleteModule

func (this *ClientImpl) DeleteModule(ctx context.Context, token string, namespace string, id string) error

func (*ClientImpl) DeleteNamespace

func (this *ClientImpl) DeleteNamespace(ctx context.Context, token string, name string) error

func (*ClientImpl) DeleteSchedule

func (this *ClientImpl) DeleteSchedule(ctx context.Context, token string, namespace string, id string) error

func (*ClientImpl) DeleteUser

func (this *ClientImpl) DeleteUser(ctx context.Context, token string, userId string) error

func (*ClientImpl) DeleteVariable

func (this *ClientImpl) DeleteVariable(ctx context.Context, token string, namespace string, id string, name string) error

func (*ClientImpl) DeploymentInstanceCount

func (this *ClientImpl) DeploymentInstanceCount(ctx context.Context, token string, namespace string, id string, version int) (result model.Count, err error)

func (*ClientImpl) DeploymentParameters

func (this *ClientImpl) DeploymentParameters(ctx context.Context, token string, namespace string, id string) (result []model.ParameterDescription, err error)

func (*ClientImpl) DeploymentsUsable added in v0.10.4

func (this *ClientImpl) DeploymentsUsable(ctx context.Context, token string, namespace string, ids []string) (result map[string]bool, err error)

func (*ClientImpl) EventEvaluations

func (this *ClientImpl) EventEvaluations(ctx context.Context, token string, namespace string, id string, options model.EventReconstructionOptions) (result model.EventReconstruction, err error)

func (*ClientImpl) GetDeployment

func (this *ClientImpl) GetDeployment(ctx context.Context, token string, namespace string, id string) (result model.Deployment, err error)

func (*ClientImpl) GetDeploymentSource added in v0.7.0

func (this *ClientImpl) GetDeploymentSource(ctx context.Context, token string, namespace string, id string, version int) (result model.ModelVersion, err error)

func (*ClientImpl) GetDeploymentVersion

func (this *ClientImpl) GetDeploymentVersion(ctx context.Context, token string, namespace string, id string, version int) (result model.DeploymentVersion, err error)

func (*ClientImpl) GetInstance

func (this *ClientImpl) GetInstance(ctx context.Context, token string, namespace string, id string) (result model.Instance, err error)

func (*ClientImpl) GetIoValue

func (this *ClientImpl) GetIoValue(ctx context.Context, token string, key string) (result model.IoValue, err error)

func (*ClientImpl) GetModel

func (this *ClientImpl) GetModel(ctx context.Context, token string, namespace string, id string) (result model.Model, err error)

func (*ClientImpl) GetModelVersion

func (this *ClientImpl) GetModelVersion(ctx context.Context, token string, namespace string, id string, version int) (result model.ModelVersion, err error)

func (*ClientImpl) GetModule

func (this *ClientImpl) GetModule(ctx context.Context, token string, namespace string, id string) (result model.Module, err error)

func (*ClientImpl) GetNamespace

func (this *ClientImpl) GetNamespace(ctx context.Context, token string, namespace string) (result model.Namespace, err error)

func (*ClientImpl) GetNetwork

func (this *ClientImpl) GetNetwork(ctx context.Context, token string, networkId string) (result model.Network, err error)

func (*ClientImpl) GetSchedule

func (this *ClientImpl) GetSchedule(ctx context.Context, token string, namespace string, id string) (result model.Schedule, err error)

func (*ClientImpl) GetStartParameters

func (this *ClientImpl) GetStartParameters(ctx context.Context, token string, namespace string, deploymentId string) (result []model.StartParameter, err error)

func (*ClientImpl) GetUserDependents

func (this *ClientImpl) GetUserDependents(ctx context.Context, token string, userId string) (result model.UserDependents, err error)

func (*ClientImpl) GetUserSettings

func (this *ClientImpl) GetUserSettings(ctx context.Context, token string, userId string) (result model.UserSettings, err error)

func (*ClientImpl) GetVariable

func (this *ClientImpl) GetVariable(ctx context.Context, token string, namespace string, id string, name string, elementId string) (result model.Variable, err error)

func (*ClientImpl) GetVariables

func (this *ClientImpl) GetVariables(ctx context.Context, token string, namespace string, id string) (result []model.Variable, err error)

func (*ClientImpl) HistoryState

func (this *ClientImpl) HistoryState(ctx context.Context, token string, namespace string, id string, options model.HistoryOptions) (result model.DebugState, err error)

func (*ClientImpl) HistoryVariable

func (this *ClientImpl) HistoryVariable(ctx context.Context, token string, namespace string, id string, name string, elementId string, options model.HistoryOptions) (result model.HistoryVariable, err error)

func (*ClientImpl) ImportNetwork added in v0.21.0

func (this *ClientImpl) ImportNetwork(ctx context.Context, token string, networkId string, doc model.GatewayExport, options model.NetworkImportOptions) (result model.NetworkImport, err error)

func (*ClientImpl) IoBulk

func (this *ClientImpl) IoBulk(ctx context.Context, token string, bulk model.IoBulk) (result []model.IoValue, err error)

func (*ClientImpl) ListActivities

func (this *ClientImpl) ListActivities(ctx context.Context, token string, namespace string, id string, options model.ActivityListOptions) (result model.ActivityPage, err error)

func (*ClientImpl) ListBlockedScripts added in v0.31.0

func (this *ClientImpl) ListBlockedScripts(ctx context.Context, token string) (result []model.BlockedScript, err error)

func (*ClientImpl) ListDeploymentVersions

func (this *ClientImpl) ListDeploymentVersions(ctx context.Context, token string, namespace string, id string, options model.PageOptions) (result model.Page[model.DeploymentVersion], err error)

func (*ClientImpl) ListDeployments

func (this *ClientImpl) ListDeployments(ctx context.Context, token string, namespace string, options model.DeploymentListOptions) (result model.Page[model.Deployment], err error)

func (*ClientImpl) ListElementStats

func (this *ClientImpl) ListElementStats(ctx context.Context, token string, namespace string, id string, run int) (result []model.ElementStats, err error)

func (*ClientImpl) ListEventDescriptions

func (this *ClientImpl) ListEventDescriptions(ctx context.Context, token string, namespace string, deploymentId string) (result []model.EventDescription, err error)

func (*ClientImpl) ListIncidents

func (this *ClientImpl) ListIncidents(ctx context.Context, token string, namespace string, options model.IncidentListOptions) (result model.Page[model.Incident], err error)

func (*ClientImpl) ListInstances

func (this *ClientImpl) ListInstances(ctx context.Context, token string, namespace string, options model.InstanceListOptions) (result model.Page[model.Instance], err error)

func (*ClientImpl) ListIoValues

func (this *ClientImpl) ListIoValues(ctx context.Context, token string, options model.IoListOptions) (result model.Page[model.IoValue], err error)

func (*ClientImpl) ListMaintenanceProcedures

func (this *ClientImpl) ListMaintenanceProcedures(ctx context.Context, token string, namespace string, id string) (result []model.MaintenanceProcedure, err error)

func (*ClientImpl) ListModelVersions

func (this *ClientImpl) ListModelVersions(ctx context.Context, token string, namespace string, id string, options model.PageOptions) (result model.Page[model.ModelVersion], err error)

func (*ClientImpl) ListModels

func (this *ClientImpl) ListModels(ctx context.Context, token string, namespace string, options model.ModelListOptions) (result model.Page[model.Model], err error)

func (*ClientImpl) ListModules

func (this *ClientImpl) ListModules(ctx context.Context, token string, namespace string, options model.ModuleListOptions) (result model.Page[model.Module], err error)

func (*ClientImpl) ListNamespaces

func (this *ClientImpl) ListNamespaces(ctx context.Context, token string) (result []model.Namespace, err error)

func (*ClientImpl) ListNetworks

func (this *ClientImpl) ListNetworks(ctx context.Context, token string) (result []model.Network, err error)

func (*ClientImpl) ListRuns

func (this *ClientImpl) ListRuns(ctx context.Context, token string, namespace string, id string) (result []model.Run, err error)

func (*ClientImpl) ListSchedules

func (this *ClientImpl) ListSchedules(ctx context.Context, token string, namespace string, options model.ScheduleListOptions) (result model.Page[model.Schedule], err error)

func (*ClientImpl) MaintenanceParameters

func (this *ClientImpl) MaintenanceParameters(ctx context.Context, token string, namespace string, id string, procedure string) (result []model.ParameterDescription, err error)

func (*ClientImpl) PrepareDeployment

func (this *ClientImpl) PrepareDeployment(ctx context.Context, token string, namespace string, input model.PrepareInput) (result model.PreparedDeployment, err error)

func (*ClientImpl) PublishModel

func (this *ClientImpl) PublishModel(ctx context.Context, token string, namespace string, id string, input model.PublishInput) (result model.Model, err error)

func (*ClientImpl) PutDeployment

func (this *ClientImpl) PutDeployment(ctx context.Context, token string, namespace string, id string, input model.DeploymentInput) (result model.Deployment, err error)

func (*ClientImpl) PutInstance

func (this *ClientImpl) PutInstance(ctx context.Context, token string, namespace string, id string, input model.StartInstanceInput) (result model.Instance, err error)

func (*ClientImpl) PutNamespace

func (this *ClientImpl) PutNamespace(ctx context.Context, token string, name string, ns model.Namespace) (result model.Namespace, err error)

func (*ClientImpl) ResetRestarts

func (this *ClientImpl) ResetRestarts(ctx context.Context, token string, namespace string, id string) (result model.Deployment, err error)

func (*ClientImpl) ResourceUsage

func (this *ClientImpl) ResourceUsage(ctx context.Context, token string, namespace string, kind string, id string) (result model.ResourceUsage, err error)

func (*ClientImpl) RestartInstance

func (this *ClientImpl) RestartInstance(ctx context.Context, token string, namespace string, id string, input model.RestartInput) (result model.Instance, err error)

func (*ClientImpl) SetDeploymentDisabled

func (this *ClientImpl) SetDeploymentDisabled(ctx context.Context, token string, namespace string, id string, input model.DisabledInput) (result model.Deployment, err error)

func (*ClientImpl) SetIoValue

func (this *ClientImpl) SetIoValue(ctx context.Context, token string, key string, input model.IoValueInput) error

func (*ClientImpl) SetOwner

func (this *ClientImpl) SetOwner(ctx context.Context, token string, namespace string, kind model.Kind, id string, input model.OwnerInput) error

func (*ClientImpl) SetUserSettings

func (this *ClientImpl) SetUserSettings(ctx context.Context, token string, userId string, settings model.UserSettings) (result model.UserSettings, err error)

func (*ClientImpl) SetVariable

func (this *ClientImpl) SetVariable(ctx context.Context, token string, namespace string, id string, name string, value any) error

func (*ClientImpl) StartInstance

func (this *ClientImpl) StartInstance(ctx context.Context, token string, namespace string, input model.StartInstanceInput) (result model.Instance, err error)

func (*ClientImpl) StartMaintenance

func (this *ClientImpl) StartMaintenance(ctx context.Context, token string, namespace string, id string, procedure string, input model.MaintenanceStartInput) (result model.Instance, err error)

func (*ClientImpl) StopInstances

func (this *ClientImpl) StopInstances(ctx context.Context, token string, namespace string, ids []string) error

func (*ClientImpl) TriggerWait added in v0.22.0

func (this *ClientImpl) TriggerWait(ctx context.Context, token string, namespace string, id string, elementId string, input model.TriggerInput) error

func (*ClientImpl) UnblockScript added in v0.31.0

func (this *ClientImpl) UnblockScript(ctx context.Context, token string, fingerprint string) error

func (*ClientImpl) UpdateInstanceInfo

func (this *ClientImpl) UpdateInstanceInfo(ctx context.Context, token string, namespace string, id string, input model.InstanceInfoInput) (result model.Instance, err error)

func (*ClientImpl) UpdateModel

func (this *ClientImpl) UpdateModel(ctx context.Context, token string, namespace string, id string, input model.ModelInput) (result model.Model, err error)

func (*ClientImpl) UpdateParameters

func (this *ClientImpl) UpdateParameters(ctx context.Context, token string, namespace string, id string, input model.ParametersInput) (result model.Instance, err error)

func (*ClientImpl) UpdateSchedule

func (this *ClientImpl) UpdateSchedule(ctx context.Context, token string, namespace string, id string, input model.ScheduleInput) (result model.Schedule, err error)

func (*ClientImpl) Validate

func (this *ClientImpl) Validate(ctx context.Context, token string, namespace string, xml string) (result []model.Issue, err error)

func (*ClientImpl) Watch

func (this *ClientImpl) Watch(ctx context.Context, token string, namespace string, id string, options model.WatchOptions) (<-chan model.DebugMessage, error)

Watch opens the live debug stream over a WebSocket (DBG-01). An error before the first message is returned typed (CLI-03); later errors arrive as message of type error.

func (*ClientImpl) WithHttpClient

func (this *ClientImpl) WithHttpClient(c *http.Client) *ClientImpl

WithHttpClient replaces the HTTP client, e.g. for other timeouts or transports.

type Follower

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

Follower keeps the debug state of an instance current from the live stream: it merges snapshot and deltas and resumes after an interruption from the last sequence (CLI-05).

func Follow

func Follow(ctx context.Context, c Client, token TokenSource, namespace string, id string, options model.WatchOptions) (*Follower, error)

Follow connects to the live stream of an instance.

func (*Follower) Next

func (this *Follower) Next(ctx context.Context) (model.DebugMessage, error)

Next waits for the next message and merges it into State. It returns io.EOF after the end message; an interrupted connection is resumed, errors of the instance are returned.

func (*Follower) State

func (this *Follower) State() model.DebugState

State is the merged state after the messages read so far.

type History

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

History steps through the reconstructed states of an instance (DBG-13, CLI-05).

func OpenHistory

func OpenHistory(ctx context.Context, c Client, token TokenSource, namespace string, id string, options model.HistoryOptions) (*History, error)

OpenHistory loads a step, without seq and time the latest.

func (*History) Back

func (this *History) Back(ctx context.Context) (bool, error)

Back moves one step back; false at the earliest step that can be reconstructed.

func (*History) Forward

func (this *History) Forward(ctx context.Context) (bool, error)

Forward moves one step on; false at the latest step.

func (*History) Jump

func (this *History) Jump(ctx context.Context, options model.HistoryOptions) error

Jump moves to a sequence or to the last step at or before a time.

func (*History) State

func (this *History) State() model.DebugState

type TestClient

type TestClient struct {
	*controller.Controller
	// to register task types or trigger due timers in tests
	Engine *engine.Engine
	// contains filtered or unexported fields
}

TestClient runs the engine in the process with an in-memory SQLite database and an in-process permissions-v2; it fulfills Client without network or container (CLI-09). Tokens are not verified, see TestToken.

func NewTestClient

func NewTestClient(ctx context.Context) (*TestClient, error)

NewTestClient starts the engine; it stops when ctx is done.

func (*TestClient) SyncPermissions

func (this *TestClient) SyncPermissions(ctx context.Context) error

SyncPermissions writes pending rights to permissions-v2 at once instead of in the next background pass, e.g. before a test shares a resource.

type TokenSource

type TokenSource func() (string, error)

TokenSource returns a current token, e.g. NewTokenProvider; streams ask again after the token expired.

Jump to

Keyboard shortcuts

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