createTask method

Future<CreateTaskOutput> createTask({
  1. required Command command,
  2. required List<String> targets,
  3. String? clientToken,
  4. String? description,
  5. Map<String, String>? tags,
})

Instructs one or more devices to start a task, such as unlocking or rebooting.

May throw AccessDeniedException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter command : The task to be performed. Only one task is executed on a device at a time.

Parameter targets : A list of managed device IDs.

Parameter clientToken : A token ensuring that the action is called only once with the specified details.

Parameter description : A description of the task and its targets.

Parameter tags : Optional metadata that you assign to a resource. You can use tags to categorize a resource in different ways, such as by purpose, owner, or environment.

Implementation

Future<CreateTaskOutput> createTask({
  required Command command,
  required List<String> targets,
  String? clientToken,
  String? description,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'command': command,
    'targets': targets,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (description != null) 'description': description,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/task',
    exceptionFnMap: _exceptionFns,
  );
  return CreateTaskOutput.fromJson(response);
}