updateJob method

Future<void> updateJob({
  1. required String farmId,
  2. required String jobId,
  3. required String queueId,
  4. String? clientToken,
  5. String? description,
  6. UpdateJobLifecycleStatus? lifecycleStatus,
  7. int? maxFailedTasksCount,
  8. int? maxRetriesPerTask,
  9. int? maxWorkerCount,
  10. String? name,
  11. int? priority,
  12. JobTargetTaskRunStatus? targetTaskRunStatus,
})

Updates a job.

When you change the status of the job to ARCHIVED, the job can't be scheduled or archived.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerErrorException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter farmId : The farm ID of the job to update.

Parameter jobId : The job ID to update.

Parameter queueId : The queue ID of the job to update.

Parameter clientToken : The unique token which the server uses to recognize retries of the same request.

Parameter description : The updated job description.

Parameter lifecycleStatus : The status of a job in its lifecycle. When you change the status of the job to ARCHIVED, the job can't be scheduled or archived.

Parameter maxFailedTasksCount : The number of task failures before the job stops running and is marked as FAILED.

Parameter maxRetriesPerTask : The maximum number of retries for a job.

Parameter maxWorkerCount : The maximum number of worker hosts that can concurrently process a job. When the maxWorkerCount is reached, no more workers will be assigned to process the job, even if the fleets assigned to the job's queue has available workers.

You can't set the maxWorkerCount to 0. If you set it to -1, there is no maximum number of workers.

If you don't specify the maxWorkerCount, the default is -1.

The maximum number of workers that can process tasks in the job.

Parameter name : The updated job name.

Parameter priority : The updated job priority.

Parameter targetTaskRunStatus : The task status to update the job's tasks to.

Implementation

Future<void> updateJob({
  required String farmId,
  required String jobId,
  required String queueId,
  String? clientToken,
  String? description,
  UpdateJobLifecycleStatus? lifecycleStatus,
  int? maxFailedTasksCount,
  int? maxRetriesPerTask,
  int? maxWorkerCount,
  String? name,
  int? priority,
  JobTargetTaskRunStatus? targetTaskRunStatus,
}) async {
  _s.validateNumRange(
    'maxFailedTasksCount',
    maxFailedTasksCount,
    0,
    2147483647,
  );
  _s.validateNumRange(
    'maxRetriesPerTask',
    maxRetriesPerTask,
    0,
    2147483647,
  );
  _s.validateNumRange(
    'maxWorkerCount',
    maxWorkerCount,
    -1,
    2147483647,
  );
  _s.validateNumRange(
    'priority',
    priority,
    0,
    100,
  );
  final headers = <String, String>{
    if (clientToken != null) 'X-Amz-Client-Token': clientToken.toString(),
  };
  final $payload = <String, dynamic>{
    if (description != null) 'description': description,
    if (lifecycleStatus != null) 'lifecycleStatus': lifecycleStatus.value,
    if (maxFailedTasksCount != null)
      'maxFailedTasksCount': maxFailedTasksCount,
    if (maxRetriesPerTask != null) 'maxRetriesPerTask': maxRetriesPerTask,
    if (maxWorkerCount != null) 'maxWorkerCount': maxWorkerCount,
    if (name != null) 'name': name,
    if (priority != null) 'priority': priority,
    if (targetTaskRunStatus != null)
      'targetTaskRunStatus': targetTaskRunStatus.value,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PATCH',
    requestUri:
        '/2023-10-12/farms/${Uri.encodeComponent(farmId)}/queues/${Uri.encodeComponent(queueId)}/jobs/${Uri.encodeComponent(jobId)}',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
}