createPullRequest method

Future<CreatePullRequestOutput> createPullRequest({
  1. required List<Target> targets,
  2. required String title,
  3. String? clientRequestToken,
  4. String? description,
})

Creates a pull request in the specified repository.

May throw RepositoryNameRequiredException. May throw InvalidRepositoryNameException. May throw RepositoryDoesNotExistException. May throw EncryptionIntegrityChecksFailedException. May throw EncryptionKeyAccessDeniedException. May throw EncryptionKeyDisabledException. May throw EncryptionKeyNotFoundException. May throw EncryptionKeyUnavailableException. May throw ClientRequestTokenRequiredException. May throw InvalidClientRequestTokenException. May throw IdempotencyParameterMismatchException. May throw ReferenceNameRequiredException. May throw InvalidReferenceNameException. May throw ReferenceDoesNotExistException. May throw ReferenceTypeNotSupportedException. May throw TitleRequiredException. May throw InvalidTitleException. May throw InvalidDescriptionException. May throw TargetsRequiredException. May throw InvalidTargetsException. May throw TargetRequiredException. May throw InvalidTargetException. May throw MultipleRepositoriesInPullRequestException. May throw MaximumOpenPullRequestsExceededException. May throw SourceAndDestinationAreSameException.

Parameter targets : The targets for the pull request, including the source of the code to be reviewed (the source branch) and the destination where the creator of the pull request intends the code to be merged after the pull request is closed (the destination branch).

Parameter title : The title of the pull request. This title is used to identify the pull request to other users in the repository.

Parameter clientRequestToken : A unique, client-generated idempotency token that, when provided in a request, ensures the request cannot be repeated with a changed parameter. If a request is received with the same parameters and a token is included, the request returns information about the initial request that used that token.

Parameter description : A description of the pull request.

Implementation

Future<CreatePullRequestOutput> createPullRequest({
  required List<Target> targets,
  required String title,
  String? clientRequestToken,
  String? description,
}) async {
  ArgumentError.checkNotNull(targets, 'targets');
  ArgumentError.checkNotNull(title, 'title');
  _s.validateStringLength(
    'title',
    title,
    0,
    150,
    isRequired: true,
  );
  _s.validateStringLength(
    'description',
    description,
    0,
    10240,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'CodeCommit_20150413.CreatePullRequest'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'targets': targets,
      'title': title,
      'clientRequestToken':
          clientRequestToken ?? _s.generateIdempotencyToken(),
      if (description != null) 'description': description,
    },
  );

  return CreatePullRequestOutput.fromJson(jsonResponse.body);
}