createJob method

Future<CreateJobResponse> createJob({
  1. required String farmId,
  2. required int priority,
  3. required String queueId,
  4. Attachments? attachments,
  5. String? clientToken,
  6. String? descriptionOverride,
  7. int? maxFailedTasksCount,
  8. int? maxRetriesPerTask,
  9. int? maxWorkerCount,
  10. String? nameOverride,
  11. Map<String, JobParameter>? parameters,
  12. String? sourceJobId,
  13. String? storageProfileId,
  14. Map<String, String>? tags,
  15. CreateJobTargetTaskRunStatus? targetTaskRunStatus,
  16. String? template,
  17. JobTemplateType? templateType,
})

Creates a job. A job is a set of instructions that Deadline Cloud uses to schedule and run work on available workers. For more information, see Deadline Cloud jobs.

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

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

Parameter priority : The priority of the job. The highest priority (first scheduled) is 100. When two jobs have the same priority, the oldest job is scheduled first.

Parameter queueId : The ID of the queue that the job is submitted to.

Parameter attachments : The attachments for the job. Attach files required for the job to run to a render job.

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

Parameter descriptionOverride : A custom description to override the job description derived from the job template.

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 each task.

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, Deadline Cloud won't throttle the number of workers used to process the job.

Parameter nameOverride : A custom name to override the job name derived from the job template.

Parameter parameters : The parameters for the job.

Parameter sourceJobId : The job ID for the source job.

Parameter storageProfileId : The storage profile ID for the storage profile to connect to the job.

Parameter tags : The tags to add to your job. Each tag consists of a tag key and a tag value. Tag keys and values are both required, but tag values can be empty strings.

Parameter targetTaskRunStatus : The initial job status when it is created. Jobs that are created with a SUSPENDED status will not run until manually requeued.

Parameter template : The job template to use for this job.

Parameter templateType : The file type for the job template.

Implementation

Future<CreateJobResponse> createJob({
  required String farmId,
  required int priority,
  required String queueId,
  Attachments? attachments,
  String? clientToken,
  String? descriptionOverride,
  int? maxFailedTasksCount,
  int? maxRetriesPerTask,
  int? maxWorkerCount,
  String? nameOverride,
  Map<String, JobParameter>? parameters,
  String? sourceJobId,
  String? storageProfileId,
  Map<String, String>? tags,
  CreateJobTargetTaskRunStatus? targetTaskRunStatus,
  String? template,
  JobTemplateType? templateType,
}) async {
  _s.validateNumRange(
    'priority',
    priority,
    0,
    100,
    isRequired: true,
  );
  _s.validateNumRange(
    'maxFailedTasksCount',
    maxFailedTasksCount,
    0,
    2147483647,
  );
  _s.validateNumRange(
    'maxRetriesPerTask',
    maxRetriesPerTask,
    0,
    2147483647,
  );
  _s.validateNumRange(
    'maxWorkerCount',
    maxWorkerCount,
    -1,
    2147483647,
  );
  final headers = <String, String>{
    if (clientToken != null) 'X-Amz-Client-Token': clientToken.toString(),
  };
  final $payload = <String, dynamic>{
    'priority': priority,
    if (attachments != null) 'attachments': attachments,
    if (descriptionOverride != null)
      'descriptionOverride': descriptionOverride,
    if (maxFailedTasksCount != null)
      'maxFailedTasksCount': maxFailedTasksCount,
    if (maxRetriesPerTask != null) 'maxRetriesPerTask': maxRetriesPerTask,
    if (maxWorkerCount != null) 'maxWorkerCount': maxWorkerCount,
    if (nameOverride != null) 'nameOverride': nameOverride,
    if (parameters != null) 'parameters': parameters,
    if (sourceJobId != null) 'sourceJobId': sourceJobId,
    if (storageProfileId != null) 'storageProfileId': storageProfileId,
    if (tags != null) 'tags': tags,
    if (targetTaskRunStatus != null)
      'targetTaskRunStatus': targetTaskRunStatus.value,
    if (template != null) 'template': template,
    if (templateType != null) 'templateType': templateType.value,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/2023-10-12/farms/${Uri.encodeComponent(farmId)}/queues/${Uri.encodeComponent(queueId)}/jobs',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return CreateJobResponse.fromJson(response);
}