postCommentForPullRequest method

Future<PostCommentForPullRequestOutput> postCommentForPullRequest({
  1. required String afterCommitId,
  2. required String beforeCommitId,
  3. required String content,
  4. required String pullRequestId,
  5. required String repositoryName,
  6. String? clientRequestToken,
  7. Location? location,
})

Posts a comment on a pull request.

May throw PullRequestDoesNotExistException. May throw InvalidPullRequestIdException. May throw PullRequestIdRequiredException. May throw RepositoryNotAssociatedWithPullRequestException. May throw RepositoryNameRequiredException. May throw RepositoryDoesNotExistException. May throw InvalidRepositoryNameException. May throw ClientRequestTokenRequiredException. May throw InvalidClientRequestTokenException. May throw IdempotencyParameterMismatchException. May throw CommentContentRequiredException. May throw CommentContentSizeLimitExceededException. May throw InvalidFileLocationException. May throw InvalidRelativeFileVersionEnumException. May throw PathRequiredException. May throw InvalidFilePositionException. May throw CommitIdRequiredException. May throw InvalidCommitIdException. May throw BeforeCommitIdAndAfterCommitIdAreSameException. May throw EncryptionIntegrityChecksFailedException. May throw EncryptionKeyAccessDeniedException. May throw EncryptionKeyDisabledException. May throw EncryptionKeyNotFoundException. May throw EncryptionKeyUnavailableException. May throw CommitDoesNotExistException. May throw InvalidPathException. May throw PathDoesNotExistException. May throw PathRequiredException.

Parameter afterCommitId : The full commit ID of the commit in the source branch that is the current tip of the branch for the pull request when you post the comment.

Parameter beforeCommitId : The full commit ID of the commit in the destination branch that was the tip of the branch at the time the pull request was created.

Parameter content : The content of your comment on the change.

Parameter pullRequestId : The system-generated ID of the pull request. To get this ID, use ListPullRequests.

Parameter repositoryName : The name of the repository where you want to post a comment on a pull request.

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 location : The location of the change where you want to post your comment. If no location is provided, the comment is posted as a general comment on the pull request difference between the before commit ID and the after commit ID.

Implementation

Future<PostCommentForPullRequestOutput> postCommentForPullRequest({
  required String afterCommitId,
  required String beforeCommitId,
  required String content,
  required String pullRequestId,
  required String repositoryName,
  String? clientRequestToken,
  Location? location,
}) async {
  ArgumentError.checkNotNull(afterCommitId, 'afterCommitId');
  ArgumentError.checkNotNull(beforeCommitId, 'beforeCommitId');
  ArgumentError.checkNotNull(content, 'content');
  ArgumentError.checkNotNull(pullRequestId, 'pullRequestId');
  ArgumentError.checkNotNull(repositoryName, 'repositoryName');
  _s.validateStringLength(
    'repositoryName',
    repositoryName,
    1,
    100,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'CodeCommit_20150413.PostCommentForPullRequest'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'afterCommitId': afterCommitId,
      'beforeCommitId': beforeCommitId,
      'content': content,
      'pullRequestId': pullRequestId,
      'repositoryName': repositoryName,
      'clientRequestToken':
          clientRequestToken ?? _s.generateIdempotencyToken(),
      if (location != null) 'location': location,
    },
  );

  return PostCommentForPullRequestOutput.fromJson(jsonResponse.body);
}