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 ¶
- func All[T any](list func(page model.PageOptions) (model.Page[T], error)) iter.Seq2[T, error]
- func NewTestServer(ctx context.Context, ...) (*server.Server, error)
- func NewTokenExchange(endpoint string, clientId string, clientSecret string) *auth.TokenExchange
- func NewTokenProvider(endpoint string, clientId string, clientSecret string) func() (string, error)
- func TestDependencies(ctx context.Context) (server.Dependencies, error)
- func TestHubOwners(owners map[string]string) devicerepository.Interface
- func TestToken(user string, roles ...string) string
- type Client
- type ClientImpl
- func (this *ClientImpl) Convert(ctx context.Context, token string, namespace string, xml string) (result model.Conversion, err error)
- func (this *ClientImpl) CorrelateMessage(ctx context.Context, token string, input model.MessageInput) (result model.CorrelationResult, err error)
- func (this *ClientImpl) CreateDeployment(ctx context.Context, token string, namespace string, ...) (result model.Deployment, err error)
- func (this *ClientImpl) CreateModel(ctx context.Context, token string, namespace string, input model.ModelInput) (result model.Model, err error)
- func (this *ClientImpl) CreateSchedule(ctx context.Context, token string, namespace string, input model.ScheduleInput) (result model.Schedule, err error)
- func (this *ClientImpl) DebugState(ctx context.Context, token string, namespace string, id string, ...) (result model.DebugState, err error)
- func (this *ClientImpl) DeleteDeployment(ctx context.Context, token string, namespace string, id string) error
- func (this *ClientImpl) DeleteInstances(ctx context.Context, token string, namespace string, ids []string) error
- func (this *ClientImpl) DeleteIoValue(ctx context.Context, token string, key string) error
- func (this *ClientImpl) DeleteModel(ctx context.Context, token string, namespace string, id string, force bool) error
- func (this *ClientImpl) DeleteModule(ctx context.Context, token string, namespace string, id string) error
- func (this *ClientImpl) DeleteNamespace(ctx context.Context, token string, name string) error
- func (this *ClientImpl) DeleteSchedule(ctx context.Context, token string, namespace string, id string) error
- func (this *ClientImpl) DeleteUser(ctx context.Context, token string, userId string) error
- func (this *ClientImpl) DeleteVariable(ctx context.Context, token string, namespace string, id string, name string) error
- func (this *ClientImpl) DeploymentInstanceCount(ctx context.Context, token string, namespace string, id string, version int) (result model.Count, err error)
- func (this *ClientImpl) DeploymentParameters(ctx context.Context, token string, namespace string, id string) (result []model.ParameterDescription, err error)
- func (this *ClientImpl) DeploymentsUsable(ctx context.Context, token string, namespace string, ids []string) (result map[string]bool, err error)
- func (this *ClientImpl) EventEvaluations(ctx context.Context, token string, namespace string, id string, ...) (result model.EventReconstruction, err error)
- func (this *ClientImpl) GetDeployment(ctx context.Context, token string, namespace string, id string) (result model.Deployment, err error)
- func (this *ClientImpl) GetDeploymentSource(ctx context.Context, token string, namespace string, id string, version int) (result model.ModelVersion, err error)
- func (this *ClientImpl) GetDeploymentVersion(ctx context.Context, token string, namespace string, id string, version int) (result model.DeploymentVersion, err error)
- func (this *ClientImpl) GetInstance(ctx context.Context, token string, namespace string, id string) (result model.Instance, err error)
- func (this *ClientImpl) GetIoValue(ctx context.Context, token string, key string) (result model.IoValue, err error)
- func (this *ClientImpl) GetModel(ctx context.Context, token string, namespace string, id string) (result model.Model, err error)
- func (this *ClientImpl) GetModelVersion(ctx context.Context, token string, namespace string, id string, version int) (result model.ModelVersion, err error)
- func (this *ClientImpl) GetModule(ctx context.Context, token string, namespace string, id string) (result model.Module, err error)
- func (this *ClientImpl) GetNamespace(ctx context.Context, token string, namespace string) (result model.Namespace, err error)
- func (this *ClientImpl) GetNetwork(ctx context.Context, token string, networkId string) (result model.Network, err error)
- func (this *ClientImpl) GetSchedule(ctx context.Context, token string, namespace string, id string) (result model.Schedule, err error)
- func (this *ClientImpl) GetStartParameters(ctx context.Context, token string, namespace string, deploymentId string) (result []model.StartParameter, err error)
- func (this *ClientImpl) GetUserDependents(ctx context.Context, token string, userId string) (result model.UserDependents, err error)
- func (this *ClientImpl) GetUserSettings(ctx context.Context, token string, userId string) (result model.UserSettings, err error)
- func (this *ClientImpl) GetVariable(ctx context.Context, token string, namespace string, id string, name string, ...) (result model.Variable, err error)
- func (this *ClientImpl) GetVariables(ctx context.Context, token string, namespace string, id string) (result []model.Variable, err error)
- func (this *ClientImpl) HistoryState(ctx context.Context, token string, namespace string, id string, ...) (result model.DebugState, err error)
- func (this *ClientImpl) HistoryVariable(ctx context.Context, token string, namespace string, id string, name string, ...) (result model.HistoryVariable, err error)
- func (this *ClientImpl) ImportNetwork(ctx context.Context, token string, networkId string, doc model.GatewayExport, ...) (result model.NetworkImport, err error)
- func (this *ClientImpl) IoBulk(ctx context.Context, token string, bulk model.IoBulk) (result []model.IoValue, err error)
- func (this *ClientImpl) ListActivities(ctx context.Context, token string, namespace string, id string, ...) (result model.ActivityPage, err error)
- func (this *ClientImpl) ListBlockedScripts(ctx context.Context, token string) (result []model.BlockedScript, err error)
- func (this *ClientImpl) ListDeploymentVersions(ctx context.Context, token string, namespace string, id string, ...) (result model.Page[model.DeploymentVersion], err error)
- func (this *ClientImpl) ListDeployments(ctx context.Context, token string, namespace string, ...) (result model.Page[model.Deployment], err error)
- func (this *ClientImpl) ListElementStats(ctx context.Context, token string, namespace string, id string, run int) (result []model.ElementStats, err error)
- func (this *ClientImpl) ListEventDescriptions(ctx context.Context, token string, namespace string, deploymentId string) (result []model.EventDescription, err error)
- func (this *ClientImpl) ListIncidents(ctx context.Context, token string, namespace string, ...) (result model.Page[model.Incident], err error)
- func (this *ClientImpl) ListInstances(ctx context.Context, token string, namespace string, ...) (result model.Page[model.Instance], err error)
- func (this *ClientImpl) ListIoValues(ctx context.Context, token string, options model.IoListOptions) (result model.Page[model.IoValue], err error)
- func (this *ClientImpl) ListMaintenanceProcedures(ctx context.Context, token string, namespace string, id string) (result []model.MaintenanceProcedure, err error)
- func (this *ClientImpl) ListModelVersions(ctx context.Context, token string, namespace string, id string, ...) (result model.Page[model.ModelVersion], err error)
- func (this *ClientImpl) ListModels(ctx context.Context, token string, namespace string, ...) (result model.Page[model.Model], err error)
- func (this *ClientImpl) ListModules(ctx context.Context, token string, namespace string, ...) (result model.Page[model.Module], err error)
- func (this *ClientImpl) ListNamespaces(ctx context.Context, token string) (result []model.Namespace, err error)
- func (this *ClientImpl) ListNetworks(ctx context.Context, token string) (result []model.Network, err error)
- func (this *ClientImpl) ListRuns(ctx context.Context, token string, namespace string, id string) (result []model.Run, err error)
- func (this *ClientImpl) ListSchedules(ctx context.Context, token string, namespace string, ...) (result model.Page[model.Schedule], err error)
- func (this *ClientImpl) MaintenanceParameters(ctx context.Context, token string, namespace string, id string, ...) (result []model.ParameterDescription, err error)
- func (this *ClientImpl) PrepareDeployment(ctx context.Context, token string, namespace string, input model.PrepareInput) (result model.PreparedDeployment, err error)
- func (this *ClientImpl) PublishModel(ctx context.Context, token string, namespace string, id string, ...) (result model.Model, err error)
- func (this *ClientImpl) PutDeployment(ctx context.Context, token string, namespace string, id string, ...) (result model.Deployment, err error)
- func (this *ClientImpl) PutInstance(ctx context.Context, token string, namespace string, id string, ...) (result model.Instance, err error)
- func (this *ClientImpl) PutNamespace(ctx context.Context, token string, name string, ns model.Namespace) (result model.Namespace, err error)
- func (this *ClientImpl) ResetRestarts(ctx context.Context, token string, namespace string, id string) (result model.Deployment, err error)
- func (this *ClientImpl) ResourceUsage(ctx context.Context, token string, namespace string, kind string, id string) (result model.ResourceUsage, err error)
- func (this *ClientImpl) RestartInstance(ctx context.Context, token string, namespace string, id string, ...) (result model.Instance, err error)
- func (this *ClientImpl) SetDeploymentDisabled(ctx context.Context, token string, namespace string, id string, ...) (result model.Deployment, err error)
- func (this *ClientImpl) SetIoValue(ctx context.Context, token string, key string, input model.IoValueInput) error
- func (this *ClientImpl) SetOwner(ctx context.Context, token string, namespace string, kind model.Kind, ...) error
- func (this *ClientImpl) SetUserSettings(ctx context.Context, token string, userId string, settings model.UserSettings) (result model.UserSettings, err error)
- func (this *ClientImpl) SetVariable(ctx context.Context, token string, namespace string, id string, name string, ...) error
- func (this *ClientImpl) StartInstance(ctx context.Context, token string, namespace string, ...) (result model.Instance, err error)
- func (this *ClientImpl) StartMaintenance(ctx context.Context, token string, namespace string, id string, ...) (result model.Instance, err error)
- func (this *ClientImpl) StopInstances(ctx context.Context, token string, namespace string, ids []string) error
- func (this *ClientImpl) TriggerWait(ctx context.Context, token string, namespace string, id string, ...) error
- func (this *ClientImpl) UnblockScript(ctx context.Context, token string, fingerprint string) error
- func (this *ClientImpl) UpdateInstanceInfo(ctx context.Context, token string, namespace string, id string, ...) (result model.Instance, err error)
- func (this *ClientImpl) UpdateModel(ctx context.Context, token string, namespace string, id string, ...) (result model.Model, err error)
- func (this *ClientImpl) UpdateParameters(ctx context.Context, token string, namespace string, id string, ...) (result model.Instance, err error)
- func (this *ClientImpl) UpdateSchedule(ctx context.Context, token string, namespace string, id string, ...) (result model.Schedule, err error)
- func (this *ClientImpl) Validate(ctx context.Context, token string, namespace string, xml string) (result []model.Issue, err error)
- func (this *ClientImpl) Watch(ctx context.Context, token string, namespace string, id string, ...) (<-chan model.DebugMessage, error)
- func (this *ClientImpl) WithHttpClient(c *http.Client) *ClientImpl
- type Follower
- type History
- type TestClient
- type TokenSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶
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 ¶
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.
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 (*ClientImpl) DeleteInstances ¶
func (*ClientImpl) DeleteIoValue ¶
func (*ClientImpl) DeleteModel ¶
func (*ClientImpl) DeleteModule ¶
func (*ClientImpl) DeleteNamespace ¶
func (*ClientImpl) DeleteSchedule ¶
func (*ClientImpl) DeleteUser ¶
func (*ClientImpl) DeleteVariable ¶
func (*ClientImpl) DeploymentInstanceCount ¶
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 (*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 (*ClientImpl) GetIoValue ¶
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) GetNamespace ¶
func (*ClientImpl) GetNetwork ¶
func (*ClientImpl) GetSchedule ¶
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 (*ClientImpl) GetVariables ¶
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) 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 (*ClientImpl) ListInstances ¶
func (*ClientImpl) ListIoValues ¶
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 (*ClientImpl) ListModules ¶
func (*ClientImpl) ListNamespaces ¶
func (*ClientImpl) ListNetworks ¶
func (*ClientImpl) ListSchedules ¶
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 (*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 (*ClientImpl) PutNamespace ¶
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 (*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) SetUserSettings ¶
func (this *ClientImpl) SetUserSettings(ctx context.Context, token string, userId string, settings model.UserSettings) (result model.UserSettings, err error)
func (*ClientImpl) SetVariable ¶
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 (*ClientImpl) StopInstances ¶
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 (*ClientImpl) UpdateInstanceInfo ¶
func (*ClientImpl) UpdateModel ¶
func (*ClientImpl) UpdateParameters ¶
func (*ClientImpl) UpdateSchedule ¶
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 ¶
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 ¶
Back moves one step back; false at the earliest step that can be reconstructed.
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 ¶
TokenSource returns a current token, e.g. NewTokenProvider; streams ask again after the token expired.