Files
binarylane-dotnet/docs/actions-and-polling.md
T
2026-08-16 21:52:42 +10:00

1.3 KiB

Server actions

Use a typed ServerAction to submit a server action. For example, this powers on a server:

using BinaryLane.Api.V2.Models;

var submission = await client.Servers.SubmitActionAsync(
    serverId,
    new PowerOnServerAction(),
    cancellationToken);

Common action types include PowerOnServerAction, PowerOffServerAction, RebootServerAction, ResizeServerAction, and RebuildServerAction.

Waiting for completion

BinaryLane can accept an action before it has finished. When the response contains an action, use its identifier to wait for the final status:

if (submission.Action is { } action)
{
    var completed = await client.Actions.WaitForCompletionAsync(
        action.Id,
        cancellationToken: cancellationToken);
}

Pass ActionWaitOptions when you need a different timeout or polling interval. The default is a 15-minute timeout with a two-second polling interval.

Status values

BinaryLaneAction.Status and BinaryLaneAction.Type are strings. Compare a documented value with BinaryLaneValues:

if (action.Status == BinaryLaneValues.ActionStatus.Completed)
{
    // Continue with the next step.
}

If an action request has an uncertain outcome, retrieve the action or server state before submitting it again.