mirror of
https://github.com/alexhopeoconnor/binarylane-dotnet.git
synced 2026-10-04 02:18:11 +10:00
1.2 KiB
1.2 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.
}