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 UnauthorizedException. May throw InternalFailureException. May throw NotFoundException. May throw LimitExceededException.

Parameter appId : The unique ID for an Amplify app.

Parameter branchName : The branch name 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 this 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 {
  ArgumentError.checkNotNull(appId, 'appId');
  _s.validateStringLength(
    'appId',
    appId,
    1,
    20,
    isRequired: true,
  );
  ArgumentError.checkNotNull(branchName, 'branchName');
  _s.validateStringLength(
    'branchName',
    branchName,
    1,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(jobType, 'jobType');
  _s.validateStringLength(
    'commitId',
    commitId,
    0,
    255,
  );
  _s.validateStringLength(
    'commitMessage',
    commitMessage,
    0,
    10000,
  );
  _s.validateStringLength(
    'jobId',
    jobId,
    0,
    255,
  );
  _s.validateStringLength(
    'jobReason',
    jobReason,
    0,
    255,
  );
  final $payload = <String, dynamic>{
    'jobType': jobType.toValue(),
    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);
}