Skip to content

get_branch

get_branch(
    *,
    config_overrides: Optional[CodeCommitClientConfig] = None,
    repository_name: Optional[RepositoryName] = None,
    branch_name: Optional[BranchName] = None,
) -> GetBranchOutput

Returns information about a repository branch, including its name and the last commit ID.

Parameters:

  • repository_name (Optional[RepositoryName], default: None ) –

    The name of the repository that contains the branch for which you want to retrieve information.

  • branch_name (Optional[BranchName], default: None ) –

    The name of the branch for which you want to retrieve information.

Raises:

Source code in docs_src/capo_codecommit/_services/code_commit.py
def get_branch(
    self,
    *,
    config_overrides: Optional[CodeCommitClientConfig] = None,
    repository_name: Optional[
        "capo_codecommit.types.repository_name.RepositoryName"
    ] = None,
    branch_name: Optional["capo_codecommit.types.branch_name.BranchName"] = None,
) -> "capo_codecommit.types.get_branch_output.GetBranchOutput":
    """<p>Returns information about a repository branch, including its name and the last commit ID.</p>

    Args:
        repository_name: <p>The name of the repository that contains the branch for which you want to retrieve information.</p>
        branch_name: <p>The name of the branch for which you want to retrieve information.</p>

    Raises:
        capo_codecommit.errors.branch_does_not_exist_exception.BranchDoesNotExistException: <p>The specified branch does not exist.</p>
        capo_codecommit.errors.branch_name_required_exception.BranchNameRequiredException: <p>A branch name is required, but 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_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.
    """

    def _handler(
        req: "OperationRequest[capo_codecommit.types.get_branch_input.GetBranchInput]",
    ) -> OperationResponse[
        "capo_codecommit.types.get_branch_output.GetBranchOutput"
    ]:
        import capo_codecommit._operations.code_commit_20150413.get_branch

        output, http_response = (
            capo_codecommit._operations.code_commit_20150413.get_branch.get_branch(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetBranch")
    )
    input_: capo_codecommit.types.get_branch_input.GetBranchInput = {}
    if repository_name is not None:
        input_["repository_name"] = repository_name
    if branch_name is not None:
        input_["branch_name"] = branch_name

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output