Skip to content

post_comment_for_pull_request async

post_comment_for_pull_request(
    pull_request_id: PullRequestId,
    repository_name: RepositoryName,
    before_commit_id: CommitId,
    after_commit_id: CommitId,
    content: Content,
    *,
    config_overrides: Optional[AsyncCodeCommitClientConfig] = None,
    location: Optional[Location] = None,
    client_request_token: Optional[ClientRequestToken] = None,
) -> PostCommentForPullRequestOutput

Posts a comment on a pull request.

Parameters:

  • pull_request_id (PullRequestId) –

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

  • repository_name (RepositoryName) –

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

  • before_commit_id (CommitId) –

    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.

  • after_commit_id (CommitId) –

    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.

  • location (Optional[Location], default: None ) –

    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.

  • content (Content) –

    The content of your comment on the change.

  • client_request_token (Optional[ClientRequestToken], default: None ) –

    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.

Raises:

Source code in docs_src/capo_codecommit/_services/async_code_commit.py
async def post_comment_for_pull_request(
    self,
    pull_request_id: "capo_codecommit.types.pull_request_id.PullRequestId",
    repository_name: "capo_codecommit.types.repository_name.RepositoryName",
    before_commit_id: "capo_codecommit.types.commit_id.CommitId",
    after_commit_id: "capo_codecommit.types.commit_id.CommitId",
    content: "capo_codecommit.types.content.Content",
    *,
    config_overrides: Optional[AsyncCodeCommitClientConfig] = None,
    location: Optional["capo_codecommit.types.location.Location"] = None,
    client_request_token: Optional[
        "capo_codecommit.types.client_request_token.ClientRequestToken"
    ] = None,
) -> "capo_codecommit.types.post_comment_for_pull_request_output.PostCommentForPullRequestOutput":
    """<p>Posts a comment on a pull request.</p>

    Args:
        pull_request_id: <p>The system-generated ID of the pull request. To get this ID, use <a>ListPullRequests</a>.</p>
        repository_name: <p>The name of the repository where you want to post a comment on a pull request.</p>
        before_commit_id: <p>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.</p>
        after_commit_id: <p>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.</p>
        location: <p>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.</p>
        content: <p>The content of your comment on the change.</p>
        client_request_token: <p>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.</p>

    Raises:
        capo_codecommit.errors.before_commit_id_and_after_commit_id_are_same_exception.BeforeCommitIdAndAfterCommitIdAreSameException: <p>The before commit ID and the after commit ID are the same, which is not valid. The before commit ID and the after commit ID must be different commit IDs.</p>
        capo_codecommit.errors.client_request_token_required_exception.ClientRequestTokenRequiredException: <p>A client request token is required. A client request token is an 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.</p>
        capo_codecommit.errors.comment_content_required_exception.CommentContentRequiredException: <p>The comment is empty. You must provide some content for a comment. The content cannot be null.</p>
        capo_codecommit.errors.comment_content_size_limit_exceeded_exception.CommentContentSizeLimitExceededException: <p>The comment is too large. Comments are limited to 10,240 characters.</p>
        capo_codecommit.errors.commit_does_not_exist_exception.CommitDoesNotExistException: <p>The specified commit does not exist or no commit was specified, and the specified repository has no default branch.</p>
        capo_codecommit.errors.commit_id_required_exception.CommitIdRequiredException: <p>A commit ID was not specified.</p>
        capo_codecommit.errors.encryption_integrity_checks_failed_exception.EncryptionIntegrityChecksFailedException: <p>An encryption integrity check failed.</p>
        capo_codecommit.errors.encryption_key_access_denied_exception.EncryptionKeyAccessDeniedException: <p>An encryption key could not be accessed.</p>
        capo_codecommit.errors.encryption_key_disabled_exception.EncryptionKeyDisabledException: <p>The encryption key is disabled.</p>
        capo_codecommit.errors.encryption_key_not_found_exception.EncryptionKeyNotFoundException: <p>No encryption key was found.</p>
        capo_codecommit.errors.encryption_key_unavailable_exception.EncryptionKeyUnavailableException: <p>The encryption key is not available.</p>
        capo_codecommit.errors.idempotency_parameter_mismatch_exception.IdempotencyParameterMismatchException: <p>The client request token is not valid. Either the token is not in a valid format, or the token has been used in a previous request and cannot be reused.</p>
        capo_codecommit.errors.invalid_client_request_token_exception.InvalidClientRequestTokenException: <p>The client request token is not valid.</p>
        capo_codecommit.errors.invalid_commit_id_exception.InvalidCommitIdException: <p>The specified commit ID is not valid.</p>
        capo_codecommit.errors.invalid_file_location_exception.InvalidFileLocationException: <p>The location of the file is not valid. Make sure that you include the file name and extension.</p>
        capo_codecommit.errors.invalid_file_position_exception.InvalidFilePositionException: <p>The position is not valid. Make sure that the line number exists in the version of the file you want to comment on.</p>
        capo_codecommit.errors.invalid_path_exception.InvalidPathException: <p>The specified path is not valid.</p>
        capo_codecommit.errors.invalid_pull_request_id_exception.InvalidPullRequestIdException: <p>The pull request ID is not valid. Make sure that you have provided the full ID and that the pull request is in the specified repository, and then try again.</p>
        capo_codecommit.errors.invalid_relative_file_version_enum_exception.InvalidRelativeFileVersionEnumException: <p>Either the enum is not in a valid format, or the specified file version enum is not valid in respect to the current file version.</p>
        capo_codecommit.errors.invalid_repository_name_exception.InvalidRepositoryNameException: <p>A specified repository name is not valid.</p> <note> <p>This exception occurs only when a specified repository name is not valid. Other exceptions occur when a required repository parameter is missing, or when a specified repository does not exist.</p> </note>
        capo_codecommit.errors.path_does_not_exist_exception.PathDoesNotExistException: <p>The specified path does not exist.</p>
        capo_codecommit.errors.path_required_exception.PathRequiredException: <p>The folderPath for a location cannot be null.</p>
        capo_codecommit.errors.pull_request_does_not_exist_exception.PullRequestDoesNotExistException: <p>The pull request ID could not be found. Make sure that you have specified the correct repository name and pull request ID, and then try again.</p>
        capo_codecommit.errors.pull_request_id_required_exception.PullRequestIdRequiredException: <p>A pull request ID is required, but none was provided.</p>
        capo_codecommit.errors.repository_does_not_exist_exception.RepositoryDoesNotExistException: <p>The specified repository does not exist.</p>
        capo_codecommit.errors.repository_name_required_exception.RepositoryNameRequiredException: <p>A repository name is required, but was not specified.</p>
        capo_codecommit.errors.repository_not_associated_with_pull_request_exception.RepositoryNotAssociatedWithPullRequestException: <p>The repository does not contain any pull requests with that pull request ID. Use GetPullRequest to verify the correct repository name for the pull request ID.</p>
        capo_codecommit.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_codecommit.types.post_comment_for_pull_request_input.PostCommentForPullRequestInput]",
    ) -> AsyncOperationResponse[
        "capo_codecommit.types.post_comment_for_pull_request_output.PostCommentForPullRequestOutput"
    ]:
        import capo_codecommit._operations.code_commit_20150413.post_comment_for_pull_request

        (
            output,
            http_response,
        ) = await capo_codecommit._operations.code_commit_20150413.post_comment_for_pull_request.async_post_comment_for_pull_request(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PostCommentForPullRequest")
    )
    input_: capo_codecommit.types.post_comment_for_pull_request_input.PostCommentForPullRequestInput = {
        "pull_request_id": pull_request_id,
        "repository_name": repository_name,
        "before_commit_id": before_commit_id,
        "after_commit_id": after_commit_id,
        "content": content,
    }
    if location is not None:
        input_["location"] = location
    if client_request_token is None:
        client_request_token = str(uuid.uuid4())
    input_["client_request_token"] = client_request_token

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output