Skip to content

create_pull_request_approval_rule async

create_pull_request_approval_rule(
    pull_request_id: PullRequestId,
    approval_rule_name: ApprovalRuleName,
    approval_rule_content: ApprovalRuleContent,
    *,
    config_overrides: Optional[AsyncCodeCommitClientConfig] = None,
) -> CreatePullRequestApprovalRuleOutput

Creates an approval rule for a pull request.

Parameters:

  • pull_request_id (PullRequestId) –

    The system-generated ID of the pull request for which you want to create the approval rule.

  • approval_rule_name (ApprovalRuleName) –

    The name for the approval rule.

  • approval_rule_content (ApprovalRuleContent) –

    The content of the approval rule, including the number of approvals needed and the structure of an approval pool defined for approvals, if any. For more information about approval pools, see the CodeCommit User Guide.

    When you create the content of the approval rule, you can specify approvers in an approval pool in one of two ways:

    • CodeCommitApprovers: This option only requires an Amazon Web Services account and a resource. It can be used for both IAM users and federated access users whose name matches the provided resource name. This is a very powerful option that offers a great deal of flexibility. For example, if you specify the Amazon Web Services account 123456789012 and Mary_Major, all of the following would be counted as approvals coming from that user:

      • An IAM user in the account (arn:aws:iam::123456789012:user/Mary_Major)

      • A federated user identified in IAM as Mary_Major (arn:aws:sts::123456789012:federated-user/Mary_Major)

      This option does not recognize an active session of someone assuming the role of CodeCommitReview with a role session name of Mary_Major (arn:aws:sts::123456789012:assumed-role/CodeCommitReview/Mary_Major) unless you include a wildcard (*Mary_Major).

    • Fully qualified ARN: This option allows you to specify the fully qualified Amazon Resource Name (ARN) of the IAM user or role.

    For more information about IAM ARNs, wildcards, and formats, see IAM Identifiers in the IAM User Guide.

Raises:

Source code in docs_src/capo_codecommit/_services/async_code_commit.py
async def create_pull_request_approval_rule(
    self,
    pull_request_id: "capo_codecommit.types.pull_request_id.PullRequestId",
    approval_rule_name: "capo_codecommit.types.approval_rule_name.ApprovalRuleName",
    approval_rule_content: "capo_codecommit.types.approval_rule_content.ApprovalRuleContent",
    *,
    config_overrides: Optional[AsyncCodeCommitClientConfig] = None,
) -> "capo_codecommit.types.create_pull_request_approval_rule_output.CreatePullRequestApprovalRuleOutput":
    """<p>Creates an approval rule for a pull request.</p>

    Args:
        pull_request_id: <p>The system-generated ID of the pull request for which you want to create the approval rule.</p>
        approval_rule_name: <p>The name for the approval rule.</p>
        approval_rule_content: <p>The content of the approval rule, including the number of approvals needed and the structure of an approval pool defined for approvals, if any. For more information about approval pools, see the CodeCommit User Guide.</p> <note> <p>When you create the content of the approval rule, you can specify approvers in an approval pool in one of two ways:</p> <ul> <li> <p> <b>CodeCommitApprovers</b>: This option only requires an Amazon Web Services account and a resource. It can be used for both IAM users and federated access users whose name matches the provided resource name. This is a very powerful option that offers a great deal of flexibility. For example, if you specify the Amazon Web Services account <i>123456789012</i> and <i>Mary_Major</i>, all of the following would be counted as approvals coming from that user:</p> <ul> <li> <p>An IAM user in the account (arn:aws:iam::<i>123456789012</i>:user/<i>Mary_Major</i>)</p> </li> <li> <p>A federated user identified in IAM as Mary_Major (arn:aws:sts::<i>123456789012</i>:federated-user/<i>Mary_Major</i>)</p> </li> </ul> <p>This option does not recognize an active session of someone assuming the role of CodeCommitReview with a role session name of <i>Mary_Major</i> (arn:aws:sts::<i>123456789012</i>:assumed-role/CodeCommitReview/<i>Mary_Major</i>) unless you include a wildcard (*Mary_Major).</p> </li> <li> <p> <b>Fully qualified ARN</b>: This option allows you to specify the fully qualified Amazon Resource Name (ARN) of the IAM user or role. </p> </li> </ul> <p>For more information about IAM ARNs, wildcards, and formats, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html">IAM Identifiers</a> in the <i>IAM User Guide</i>.</p> </note>

    Raises:
        capo_codecommit.errors.approval_rule_content_required_exception.ApprovalRuleContentRequiredException: <p>The content for the approval rule is empty. You must provide some content for an approval rule. The content cannot be null.</p>
        capo_codecommit.errors.approval_rule_name_already_exists_exception.ApprovalRuleNameAlreadyExistsException: <p>An approval rule with that name already exists. Approval rule names must be unique within the scope of a pull request.</p>
        capo_codecommit.errors.approval_rule_name_required_exception.ApprovalRuleNameRequiredException: <p>An approval rule 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_content_exception.InvalidApprovalRuleContentException: <p>The content for the approval rule is not valid.</p>
        capo_codecommit.errors.invalid_approval_rule_name_exception.InvalidApprovalRuleNameException: <p>The name for the approval rule 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.number_of_rules_exceeded_exception.NumberOfRulesExceededException: <p>The approval rule cannot be added. The pull request has the maximum number of approval rules associated with it.</p>
        capo_codecommit.errors.pull_request_already_closed_exception.PullRequestAlreadyClosedException: <p>The pull request status cannot be updated because it is already closed.</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.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_codecommit.types.create_pull_request_approval_rule_input.CreatePullRequestApprovalRuleInput]",
    ) -> AsyncOperationResponse[
        "capo_codecommit.types.create_pull_request_approval_rule_output.CreatePullRequestApprovalRuleOutput"
    ]:
        import capo_codecommit._operations.code_commit_20150413.create_pull_request_approval_rule

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreatePullRequestApprovalRule")
    )
    input_: capo_codecommit.types.create_pull_request_approval_rule_input.CreatePullRequestApprovalRuleInput = {
        "pull_request_id": pull_request_id,
        "approval_rule_name": approval_rule_name,
        "approval_rule_content": approval_rule_content,
    }

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