Skip to content

associate_approval_rule_template_with_repository

associate_approval_rule_template_with_repository(
    approval_rule_template_name: ApprovalRuleTemplateName,
    repository_name: RepositoryName,
    *,
    config_overrides: Optional[CodeCommitClientConfig] = None,
) -> None

Creates an association between an approval rule template and a specified repository. Then, the next time a pull request is created in the repository where the destination reference (if specified) matches the destination reference (branch) for the pull request, an approval rule that matches the template conditions is automatically created for that pull request. If no destination references are specified in the template, an approval rule that matches the template contents is created for all pull requests in that repository.

Parameters:

  • approval_rule_template_name (ApprovalRuleTemplateName) –

    The name for the approval rule template.

  • repository_name (RepositoryName) –

    The name of the repository that you want to associate with the template.

Raises:

Source code in docs_src/capo_codecommit/_services/code_commit.py
def associate_approval_rule_template_with_repository(
    self,
    approval_rule_template_name: "capo_codecommit.types.approval_rule_template_name.ApprovalRuleTemplateName",
    repository_name: "capo_codecommit.types.repository_name.RepositoryName",
    *,
    config_overrides: Optional[CodeCommitClientConfig] = None,
) -> None:
    """<p>Creates an association between an approval rule template and a specified repository. Then, the next time a pull request is created in the repository where the destination reference (if specified) matches the destination reference (branch) for the pull request, an approval rule that matches the template conditions is automatically created for that pull request. If no destination references are specified in the template, an approval rule that matches the template contents is created for all pull requests in that repository.</p>

    Args:
        approval_rule_template_name: <p>The name for the approval rule template. </p>
        repository_name: <p>The name of the repository that you want to associate with the template.</p>

    Raises:
        capo_codecommit.errors.approval_rule_template_does_not_exist_exception.ApprovalRuleTemplateDoesNotExistException: <p>The specified approval rule template does not exist. Verify that the name is correct and that you are signed in to the Amazon Web Services Region where the template was created, and then try again.</p>
        capo_codecommit.errors.approval_rule_template_name_required_exception.ApprovalRuleTemplateNameRequiredException: <p>An approval rule template 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_approval_rule_template_name_exception.InvalidApprovalRuleTemplateNameException: <p>The name of the approval rule template is not valid. Template names must be between 1 and 100 valid characters in length. For more information about limits in CodeCommit, see <a href="https://docs.aws.amazon.com/codecommit/latest/userguide/limits.html">Quotas</a> in the <i>CodeCommit User Guide</i>.</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.maximum_rule_templates_associated_with_repository_exception.MaximumRuleTemplatesAssociatedWithRepositoryException: <p>The maximum number of approval rule templates for a repository has been exceeded. You cannot associate more than 25 approval rule templates with a repository.</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.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_codecommit.types.associate_approval_rule_template_with_repository_input.AssociateApprovalRuleTemplateWithRepositoryInput]",
    ) -> OperationResponse[None]:
        import capo_codecommit._operations.code_commit_20150413.associate_approval_rule_template_with_repository

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

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("AssociateApprovalRuleTemplateWithRepository"),
    )
    input_: capo_codecommit.types.associate_approval_rule_template_with_repository_input.AssociateApprovalRuleTemplateWithRepositoryInput = {
        "approval_rule_template_name": approval_rule_template_name,
        "repository_name": repository_name,
    }

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