Skip to content

create_pull_request async

create_pull_request(
    title: Title,
    targets: TargetList,
    *,
    config_overrides: Optional[AsyncCodeCommitClientConfig] = None,
    description: Optional[Description] = None,
    client_request_token: Optional[ClientRequestToken] = None,
) -> CreatePullRequestOutput

Creates a pull request in the specified repository.

Parameters:

  • title (Title) –

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

  • description (Optional[Description], default: None ) –

    A description of the pull request.

  • targets (TargetList) –

    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).

  • 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.

    The Amazon Web ServicesSDKs prepopulate client request tokens. If you are using an Amazon Web ServicesSDK, an idempotency token is created for you.

Raises:

Source code in docs_src/capo_codecommit/_services/async_code_commit.py
async def create_pull_request(
    self,
    title: "capo_codecommit.types.title.Title",
    targets: "capo_codecommit.types.target_list.TargetList",
    *,
    config_overrides: Optional[AsyncCodeCommitClientConfig] = None,
    description: Optional["capo_codecommit.types.description.Description"] = None,
    client_request_token: Optional[
        "capo_codecommit.types.client_request_token.ClientRequestToken"
    ] = None,
) -> "capo_codecommit.types.create_pull_request_output.CreatePullRequestOutput":
    """<p>Creates a pull request in the specified repository.</p>

    Args:
        title: <p>The title of the pull request. This title is used to identify the pull request to other users in the repository.</p>
        description: <p>A description of the pull request.</p>
        targets: <p>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).</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> <note> <p>The Amazon Web ServicesSDKs prepopulate client request tokens. If you are using an Amazon Web ServicesSDK, an idempotency token is created for you.</p> </note>

    Raises:
        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.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_description_exception.InvalidDescriptionException: <p>The pull request description is not valid. Descriptions cannot be more than 1,000 characters.</p>
        capo_codecommit.errors.invalid_reference_name_exception.InvalidReferenceNameException: <p>The specified reference name format is not valid. Reference names must conform to the Git references format (for example, refs/heads/main). For more information, see <a href="https://git-scm.com/book/en/v2/Git-Internals-Git-References">Git Internals - Git References</a> or consult your Git documentation.</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.invalid_target_exception.InvalidTargetException: <p>The target for the pull request is not valid. A target must contain the full values for the repository name, source branch, and destination branch for the pull request.</p>
        capo_codecommit.errors.invalid_targets_exception.InvalidTargetsException: <p>The targets for the pull request is not valid or not in a valid format. Targets are a list of target objects. Each target object must contain the full values for the repository name, source branch, and destination branch for a pull request.</p>
        capo_codecommit.errors.invalid_title_exception.InvalidTitleException: <p>The title of the pull request is not valid. Pull request titles cannot exceed 100 characters in length.</p>
        capo_codecommit.errors.maximum_open_pull_requests_exceeded_exception.MaximumOpenPullRequestsExceededException: <p>You cannot create the pull request because the repository has too many open pull requests. The maximum number of open pull requests for a repository is 1,000. Close one or more open pull requests, and then try again.</p>
        capo_codecommit.errors.multiple_repositories_in_pull_request_exception.MultipleRepositoriesInPullRequestException: <p>You cannot include more than one repository in a pull request. Make sure you have specified only one repository name in your request, and then try again.</p>
        capo_codecommit.errors.reference_does_not_exist_exception.ReferenceDoesNotExistException: <p>The specified reference does not exist. You must provide a full commit ID.</p>
        capo_codecommit.errors.reference_name_required_exception.ReferenceNameRequiredException: <p>A reference name is required, but none was provided.</p>
        capo_codecommit.errors.reference_type_not_supported_exception.ReferenceTypeNotSupportedException: <p>The specified reference is not a supported type. </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.source_and_destination_are_same_exception.SourceAndDestinationAreSameException: <p>The source branch and destination branch for the pull request are the same. You must specify different branches for the source and destination.</p>
        capo_codecommit.errors.target_required_exception.TargetRequiredException: <p>A pull request target is required. It cannot be empty or null. A pull request target must contain the full values for the repository name, source branch, and destination branch for the pull request.</p>
        capo_codecommit.errors.targets_required_exception.TargetsRequiredException: <p>An array of target objects is required. It cannot be empty or null.</p>
        capo_codecommit.errors.title_required_exception.TitleRequiredException: <p>A pull request title is required. It cannot be empty or null.</p>
        capo_codecommit.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_codecommit.types.create_pull_request_input.CreatePullRequestInput]",
    ) -> AsyncOperationResponse[
        "capo_codecommit.types.create_pull_request_output.CreatePullRequestOutput"
    ]:
        import capo_codecommit._operations.code_commit_20150413.create_pull_request

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreatePullRequest")
    )
    input_: capo_codecommit.types.create_pull_request_input.CreatePullRequestInput = {
        "title": title,
        "targets": targets,
    }
    if description is not None:
        input_["description"] = description
    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