Skip to content

create_branch async

create_branch(
    repository_name: RepositoryName,
    branch_name: BranchName,
    commit_id: CommitId,
    *,
    config_overrides: Optional[AsyncCodeCommitClientConfig] = None,
) -> None

Creates a branch in a repository and points the branch to a commit.

Calling the create branch operation does not set a repository's default branch. To do this, call the update default branch operation.

Parameters:

  • repository_name (RepositoryName) –

    The name of the repository in which you want to create the new branch.

  • branch_name (BranchName) –

    The name of the new branch to create.

  • commit_id (CommitId) –

    The ID of the commit to point the new branch to.

Raises:

Source code in docs_src/capo_codecommit/_services/async_code_commit.py
async def create_branch(
    self,
    repository_name: "capo_codecommit.types.repository_name.RepositoryName",
    branch_name: "capo_codecommit.types.branch_name.BranchName",
    commit_id: "capo_codecommit.types.commit_id.CommitId",
    *,
    config_overrides: Optional[AsyncCodeCommitClientConfig] = None,
) -> None:
    """<p>Creates a branch in a repository and points the branch to a commit.</p> <note> <p>Calling the create branch operation does not set a repository's default branch. To do this, call the update default branch operation.</p> </note>

    Args:
        repository_name: <p>The name of the repository in which you want to create the new branch.</p>
        branch_name: <p>The name of the new branch to create.</p>
        commit_id: <p>The ID of the commit to point the new branch to.</p>

    Raises:
        capo_codecommit.errors.branch_name_exists_exception.BranchNameExistsException: <p>Cannot create the branch with the specified name because the commit conflicts with an existing branch with the same name. Branch names must be unique.</p>
        capo_codecommit.errors.branch_name_required_exception.BranchNameRequiredException: <p>A branch name is required, but was not specified.</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.invalid_branch_name_exception.InvalidBranchNameException: <p>The specified reference name 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_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.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.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_codecommit.types.create_branch_input.CreateBranchInput]",
    ) -> AsyncOperationResponse[None]:
        import capo_codecommit._operations.code_commit_20150413.create_branch

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateBranch")
    )
    input_: capo_codecommit.types.create_branch_input.CreateBranchInput = {
        "repository_name": repository_name,
        "branch_name": branch_name,
        "commit_id": commit_id,
    }

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