createTask method

Future<CreateTaskResponse> createTask({
  1. required TaskConfiguration taskConfiguration,
  2. required String taskName,
  3. required String workspaceName,
  4. String? clientToken,
  5. String? description,
  6. Map<String, String>? tags,
})

Creates a new task in the specified workspace. A task defines a reusable containerized compute workload that can be referenced by one or more pipeline compute nodes.

Specify a containerTaskConfiguration for custom container workloads with configurable ECR image, processing type, processing unit, and environment variables.

May throw AccessDeniedException. May throw ConflictingOperationException. May throw InternalFailureException. May throw InvalidRequestException. May throw LimitExceededException. May throw ResourceNotFoundException. May throw ThrottlingException.

Parameter taskConfiguration : The task execution configuration. Specify a containerTaskConfiguration for custom container workloads.

Parameter taskName : The name of the task to create. Must be unique within the workspace.

Parameter workspaceName : The name of the workspace.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you retry a request that completed successfully using the same client token, the server returns the cached result from the original successful request without performing the operation again.

Parameter description : A description of the task.

Parameter tags : A list of key-value pairs that contain metadata for the task. For more information, see Tagging your AWS IoT SiteWise resources in the AWS IoT SiteWise User Guide.

Implementation

Future<CreateTaskResponse> createTask({
  required TaskConfiguration taskConfiguration,
  required String taskName,
  required String workspaceName,
  String? clientToken,
  String? description,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'taskConfiguration': taskConfiguration,
    'taskName': taskName,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (description != null) 'description': description,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/workspaces/${Uri.encodeComponent(workspaceName)}/tasks',
    hostPrefix: 'api.',
    exceptionFnMap: _exceptionFns,
  );
  return CreateTaskResponse.fromJson(response);
}