startJob method

Future<StartJobResult> startJob({
  1. required String appId,
  2. required String branchName,
  3. required JobType jobType,
  4. String? commitId,
  5. String? commitMessage,
  6. DateTime? commitTime,
  7. String? jobId,
  8. String? jobReason,
})

Starts a new job for a branch of an Amplify app.

May throw BadRequestException. May throw InternalFailureException. May throw LimitExceededException. May throw NotFoundException. May throw UnauthorizedException.

Parameter appId : The unique ID for an Amplify app.

Parameter branchName : The name of the branch to use for the job.

Parameter jobType : Describes the type for the job. The job type RELEASE starts a new job with the latest change from the specified branch. This value is available only for apps that are connected to a repository.

The job type RETRY retries an existing job. If the job type value is RETRY, the jobId is also required.

Parameter commitId : The commit ID from a third-party repository provider for the job.

Parameter commitMessage : The commit message from a third-party repository provider for the job.

Parameter commitTime : The commit date and time for the job.

Parameter jobId : The unique ID for an existing job. This is required if the value of jobType is RETRY.

Parameter jobReason : A descriptive reason for starting the job.

Implementation

Future<StartJobResult> startJob({
  required String appId,
  required String branchName,
  required JobType jobType,
  String? commitId,
  String? commitMessage,
  DateTime? commitTime,
  String? jobId,
  String? jobReason,
}) async {
  final $payload = <String, dynamic>{
    'jobType': jobType.value,
    if (commitId != null) 'commitId': commitId,
    if (commitMessage != null) 'commitMessage': commitMessage,
    if (commitTime != null) 'commitTime': unixTimestampToJson(commitTime),
    if (jobId != null) 'jobId': jobId,
    if (jobReason != null) 'jobReason': jobReason,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/apps/${Uri.encodeComponent(appId)}/branches/${Uri.encodeComponent(branchName)}/jobs',
    exceptionFnMap: _exceptionFns,
  );
  return StartJobResult.fromJson(response);
}