ITaskExecutionContext
Interface in Oadm.Sdk.Plugins · Oadm.Sdk.dll
What the server gives one task while it runs on one device.
public interface ITaskExecutionContextGuide: Task plugins
Properties
Section titled “Properties”AxisDownloads
Section titled “AxisDownloads”IAxisDownloads? AxisDownloads { get; }Default implementation
Files from axis.com with the MyAxis sign-in of the user who started the task (SDK 0.9.0, docs/spec/myaxis.md). Null on older hosts and for tasks the system started.
Caller
Section titled “Caller”ICallContext? Caller { get; }Default implementation
The user who started the task, with the devices that user may reach (SDK 0.4.0): a task that reads or changes other devices than its own (a source device) goes through it. Null for tasks the system started and on older hosts.
IUploadedFiles Files { get; }Files uploaded by the dialog (firmware, ACAP packages), referenced by id in the payload.
License
Section titled “License”IPluginLicense? License { get; }Default implementation
The license of the plugin’s package (plugin.json license): check IPluginLicense.IsValid, IPluginLicense.Has or IPluginLicense.Limit before work that needs it. Null on hosts without licenses.
Logger
Section titled “Logger”ILogger Logger { get; }The server log. For what the user should read, use ITaskExecutionContext.Log.
Network
Section titled “Network”IDeviceNetwork? Network { get; }Default implementation
Network checks towards this task’s device, routed like it (through its site or on the server’s own network): the address-in-use check, the device’s host name, OADM’s address towards the device. Null on hosts without it.
ICorePlugin? Owner { get; }Set when the task was contributed by a core plugin.
IProLicense? Pro { get; }Default implementation
The server’s OADM PRO license, live (IProLicense.Changed): whether PRO is active, the plan, the devices and the last day. OADM only checks; a PRO plugin decides what runs without it. Null on hosts without licenses.
TaskId
Section titled “TaskId”Guid TaskId { get; }The id of this task (one device).
IVapixClient Vapix { get; }Pre-authenticated for the current device.
Methods
Section titled “Methods”BeginStep
Section titled “BeginStep”ITaskStep BeginStep(string name)Default implementation
Starts the named step (activating the planned step of that name) and returns it; see ITaskStep for the end rules. Every device request and every wait is its own step. Use using var step = ctx.BeginStep("...") or the helper TaskStepExtensions.StepAsync. A running step is completed when the next one begins.
CreateClientForAsync
Section titled “CreateClientForAsync”Task<IVapixClient> CreateClientForAsync(string address, CancellationToken ct)Default implementation
A VAPIX client for the current device at another address (e.g. the static address the plugin just set), with the stored credentials, the device’s scheme and its pinned certificate. The caller owns the client: dispose it when it implements IDisposable. Read requests only until the identity is verified.
void Log(TaskLogLevel level, string message)Entry in this task’s log, per device, shown in the task details and persisted. Never log secrets.
ManagedAddressesAsync
Section titled “ManagedAddressesAsync”Task<IReadOnlySet<string>> ManagedAddressesAsync(IReadOnlyCollection<string> addresses, CancellationToken ct)Default implementation
Which of addresses another managed device on this task’s route uses, also a device outside the view of the user who started the task (SDK 0.4.0): the run-time twin of ITaskQueryContext.ManagedAddressesAsync, for a task that sets a static address and must refuse one in use before the first write. Answers only “in use” and never names that device; the task’s own device does not count. Addresses are compared as IP addresses; the answer holds the entries of addresses as given. At most 256 addresses per call (more throw ArgumentException). Default (older hosts): none.
MarkCredentialsInvalid
Section titled “MarkCredentialsInvalid”void MarkCredentialsInvalid()Default implementation
The device no longer accepts the credentials OADM stored (factory default, password reset): the server deletes them and refreshes the device, which then shows PasswordNotSet or CredentialsRequired. Logged in the task log (without secrets).
PlanSteps
Section titled “PlanSteps”void PlanSteps(params string[] names)Default implementation
Announces the steps the task will (probably) run, in order, so the user sees them as Pending from the start. Optional: ITaskExecutionContext.BeginStep also adds steps that were not planned. Planned steps that never run end as Skipped. Name steps in the imperative, short and specific (“Upload AXIS OS to the device”).
ReportProgress
Section titled “ReportProgress”void ReportProgress(int percent, string? message = null)Overall progress of the task with an optional status message. Optional when the plugin uses steps: without explicit calls the progress is derived from the steps (each step weighs the same; the running one counts with its own ITaskStep.ReportProgress). Once called, this value wins.
ReportWarning
Section titled “ReportWarning”void ReportWarning(string message)The device finishes as “Done with warnings” (unless it fails); the message is logged.
SaveResultFileAsync
Section titled “SaveResultFileAsync”Task SaveResultFileAsync(string fileName, string contentType, Stream content, CancellationToken ct)Default implementation
Keeps a file the task made as its result (SDK 0.13.0, docs/spec/mcp.md “Files”): an exported configuration, a report. The host keeps it for a day (or until it restarts) for the user who started the task, who fetches it with the task (an agent’s download link, the assistant’s file card); one file per task, a second call replaces it. At most TaskResultFile.MaxBytes; never a secret the user did not ask for, never a private key. Older hosts and tasks the system started throw NotSupportedException.
Parameters
fileName: The file name the user gets (no folder), e.g. “config-ACCC8E012345.txt”.contentType: Its media type, e.g. “text/plain”, “application/pdf”.content: The bytes, read once from its position to the end.ct: Ends the copy.
UpdateCredentialsAsync
Section titled “UpdateCredentialsAsync”Task UpdateCredentialsAsync(string userName, string password, CancellationToken ct)Default implementation
Stores new credentials for the current device (encrypted, never logged), e.g. after the plugin changed the password of the account OADM uses. Afterwards ITaskExecutionContext.Vapix returns a client with the new credentials; re-read it instead of keeping the old instance.
UpdateDeviceAddressAsync
Section titled “UpdateDeviceAddressAsync”Task<bool> UpdateDeviceAddressAsync(string newAddress, CancellationToken ct)Default implementation
Moves OADM’s device record to newAddress so the device stays managed after it was re-addressed. The server first checks that the device answering there has the same serial number (throws DeviceIdentityException otherwise, the record is unchanged), keeps credentials and certificate pin, publishes the change and queues a full refresh; afterwards ITaskExecutionContext.Vapix uses the new address. Returns false when nothing was changed because OADM reaches the device by host name (added by its DNS name or a typed name) or the record already has that address.
UpdateDeviceTlsAsync
Section titled “UpdateDeviceTlsAsync”Task UpdateDeviceTlsAsync(string scheme, string? expectedFingerprintSha256, CancellationToken ct)Default implementation
Updates how OADM connects to the current device after the plugin changed its web server: with scheme “https” the device must present the certificate with the SHA-256 fingerprint expectedFingerprintSha256 (hex, separators ignored; null = accept and pin the presented one), with “http” OADM connects over plain HTTP (Digest only). The server connects with the new scheme, verifies the serial number like ITaskExecutionContext.UpdateDeviceAddressAsync, then stores scheme, certificate pin and certificate details (so the device never shows CertificateChanged), publishes the change and queues a full refresh; afterwards ITaskExecutionContext.Vapix uses the new connection. Throws DeviceIdentityException when the device does not answer with the new scheme, has another serial number or presents another certificate; the record is then unchanged.