Skip to content

get_resource_policy

get_resource_policy(
    resource_arn: ResourcePolicyResourceArn,
    *,
    config_overrides: Optional[ContextClientConfig] = None,
) -> GetResourcePolicyResponse

Returns the resource-based policy attached to an agent context, with its revision ID.

Parameters:

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.

  • 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:

Get the resource-based policy of an agent context The following example returns the resource-based policy attached to an agent context, with the revision ID to pass to PutResourcePolicy or DeleteResourcePolicy.

>>> client.get_resource_policy(resource_arn='arn:aws:context:us-east-1:111122223333:agent-context/ac-3f9c2e7a1b8d4c56a0e4f7b29d1c8e53')
Get the policy of an agent context that has none, which fails with ResourceNotFoundException
The following example shows the ResourceNotFoundException returned when no resource-based policy is attached to the agent context.
>>> client.get_resource_policy(resource_arn='arn:aws:context:us-east-1:111122223333:agent-context/ac-8d2b6f1e4a9c4e37b5d0a2c8f6e1b394')
Source code in docs_src/capo_context/_services/context.py
def get_resource_policy(
    self,
    resource_arn: "capo_context.types.resource_policy_resource_arn.ResourcePolicyResourceArn",
    *,
    config_overrides: Optional[ContextClientConfig] = None,
) -> "capo_context.types.get_resource_policy_response.GetResourcePolicyResponse":
    """<p>Returns the resource-based policy attached to an agent context, with its revision ID.</p>

    Args:
        resource_arn: <p>ARN of the agent context.</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.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:
        Get the resource-based policy of an agent context
        The following example returns the resource-based policy attached to an agent context, with the revision ID to pass to PutResourcePolicy or DeleteResourcePolicy.

        >>> client.get_resource_policy(resource_arn='arn:aws:context:us-east-1:111122223333:agent-context/ac-3f9c2e7a1b8d4c56a0e4f7b29d1c8e53')
        Get the policy of an agent context that has none, which fails with ResourceNotFoundException
        The following example shows the ResourceNotFoundException returned when no resource-based policy is attached to the agent context.

        >>> client.get_resource_policy(resource_arn='arn:aws:context:us-east-1:111122223333:agent-context/ac-8d2b6f1e4a9c4e37b5d0a2c8f6e1b394')
    """

    def _handler(
        req: "OperationRequest[capo_context.types.get_resource_policy_request.GetResourcePolicyRequest]",
    ) -> OperationResponse[
        "capo_context.types.get_resource_policy_response.GetResourcePolicyResponse"
    ]:
        import capo_context._operations.context.get_resource_policy

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetResourcePolicy")
    )
    input_: capo_context.types.get_resource_policy_request.GetResourcePolicyRequest = {
        "resource_arn": resource_arn
    }

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