pingMachine method

Future<PingMachineResponse?> pingMachine(
  1. String account,
  2. String machine
)

Ping heartbeat

Action to begin or maintain a machine heartbeat monitor. When a machine has not performed a heartbeat ping within the monitor window, it will automatically be deactivated. This can be utilized for machine leasing, where a license has a limited number of machines allowed, and each machine must maintain heartbeat pings in order to remain active. To illustrate further, consider a rather common scenario when dealing with leasing VMs: - The machine is activated for a new device using a unique VM GUID as a "fingerprint." - The machine sends their first heartbeat ping, starting the monitor. - The machine sends further heartbeat pings, within the heartbeat monitor window, to indicate that it is still alive. - The machine/software crashes. Normal machine deactivation fails to occur before the software program exits. This is now a "zombie" machine. - The heartbeat monitor detects that the machine has not sent a ping within the window, and subsequently deactivates the machine. The default heartbeat monitor window is 10 minutes from time of last ping. This can be configured via the license policy's heartbeatDuration attribute. Machines will be culled according to the policy's heartbeat cull strategy, after the machine's resurrection period has passed, if set.

Parameters:

  • String account (required): The identifier (UUID) or slug of your Keygen account.

  • String machine (required): The identifier (UUID) or URL-safe fingerprint of the machine to ping.

Implementation

Future<PingMachineResponse?> pingMachine(String account, String machine,) async {
  final response = await pingMachineWithHttpInfo(account, machine,);
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'PingMachineResponse',) as PingMachineResponse;

  }
  return null;
}