Skip to content

delete_resource_policy

delete_resource_policy(
    resource_arn: ResourcePolicyResourceArn,
    *,
    config_overrides: Optional[ContextClientConfig] = None,
    expected_revision_id: Optional[RevisionId] = None,
) -> DeleteResourcePolicyResponse

Removes the resource-based policy from an agent context.

Parameters:

  • resource_arn (ResourcePolicyResourceArn) –

    ARN of the agent context.

  • expected_revision_id (Optional[RevisionId], default: None ) –

    The revision that you last read. The delete succeeds only if it matches the stored revision.

Raises:

  • AccessDeniedException –

    You don't have sufficient access to perform this operation. Verify that you have permission to perform the operation on the resource.

  • InternalServerException –

    The request failed because of an internal error. Retry the request.

  • ThrottlingException –

    The request was denied because it exceeded a request rate quota. Wait, then retry the request.

  • ValidationException –

    The input fails to satisfy the constraints of the operation. Correct the input before you retry the request.

  • ConflictException –

    The request conflicts with the current state of the resource. Check the resource's current state before you retry the request.

  • ResourceNotFoundException –

    The specified resource was not found. Check that the ID is correct and that the resource exists in your account and Region.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

Remove the resource-based policy from an agent context The following example removes the resource-based policy from an agent context, only if the stored policy is still at the given revision.

>>> client.delete_resource_policy(resource_arn='arn:aws:context:us-east-1:111122223333:agent-context/ac-3f9c2e7a1b8d4c56a0e4f7b29d1c8e53', expected_revision_id='9a4f2c6e-1d8b-4b3a-a7e5-0c2d6f8b1e49')
Source code in docs_src/capo_context/_services/context.py
def delete_resource_policy(
    self,
    resource_arn: "capo_context.types.resource_policy_resource_arn.ResourcePolicyResourceArn",
    *,
    config_overrides: Optional[ContextClientConfig] = None,
    expected_revision_id: Optional[
        "capo_context.types.revision_id.RevisionId"
    ] = None,
) -> "capo_context.types.delete_resource_policy_response.DeleteResourcePolicyResponse":
    """<p>Removes the resource-based policy from an agent context.</p>

    Args:
        resource_arn: <p>ARN of the agent context.</p>
        expected_revision_id: <p>The revision that you last read. The delete succeeds only if it matches the stored revision.</p>

    Raises:
        capo_context.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this operation. Verify that you have permission to perform the operation on the resource.</p>
        capo_context.errors.internal_server_exception.InternalServerException: <p>The request failed because of an internal error. Retry the request.</p>
        capo_context.errors.throttling_exception.ThrottlingException: <p>The request was denied because it exceeded a request rate quota. Wait, then retry the request.</p>
        capo_context.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints of the operation. Correct the input before you retry the request.</p>
        capo_context.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of the resource. Check the resource's current state before you retry the request.</p>
        capo_context.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource was not found. Check that the ID is correct and that the resource exists in your account and Region.</p>
        capo_context.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Remove the resource-based policy from an agent context
        The following example removes the resource-based policy from an agent context, only if the stored policy is still at the given revision.

        >>> client.delete_resource_policy(resource_arn='arn:aws:context:us-east-1:111122223333:agent-context/ac-3f9c2e7a1b8d4c56a0e4f7b29d1c8e53', expected_revision_id='9a4f2c6e-1d8b-4b3a-a7e5-0c2d6f8b1e49')
    """

    def _handler(
        req: "OperationRequest[capo_context.types.delete_resource_policy_request.DeleteResourcePolicyRequest]",
    ) -> OperationResponse[
        "capo_context.types.delete_resource_policy_response.DeleteResourcePolicyResponse"
    ]:
        import capo_context._operations.context.delete_resource_policy

        output, http_response = (
            capo_context._operations.context.delete_resource_policy.delete_resource_policy(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteResourcePolicy")
    )
    input_: capo_context.types.delete_resource_policy_request.DeleteResourcePolicyRequest = {
        "resource_arn": resource_arn
    }
    if expected_revision_id is not None:
        input_["expected_revision_id"] = expected_revision_id

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