Skip to content

delete_policy

delete_policy(
    policy_engine_id: ResourceId,
    policy_id: ResourceId,
    *,
    config_overrides: Optional[BedrockAgentCoreControlClientConfig] = None,
) -> DeletePolicyResponse

Deletes an existing policy from the AgentCore Policy system. Once deleted, the policy can no longer be used for agent behavior control and all references to it become invalid. This is an asynchronous operation. Use the GetPolicy operation to poll the status field to track completion.

Parameters:

  • policy_engine_id (ResourceId) –

    The identifier of the policy engine that manages the policy to be deleted. This ensures the policy is deleted from the correct policy engine context.

  • policy_id (ResourceId) –

    The unique identifier of the policy to be deleted. This must be a valid policy ID that exists within the specified policy engine.

Raises:

Source code in docs_src/capo_bedrock_agentcore_control/_services/bedrock_agent_core_control.py
def delete_policy(
    self,
    policy_engine_id: "capo_bedrock_agentcore_control.types.resource_id.ResourceId",
    policy_id: "capo_bedrock_agentcore_control.types.resource_id.ResourceId",
    *,
    config_overrides: Optional[BedrockAgentCoreControlClientConfig] = None,
) -> "capo_bedrock_agentcore_control.types.delete_policy_response.DeletePolicyResponse":
    """<p>Deletes an existing policy from the AgentCore Policy system. Once deleted, the policy can no longer be used for agent behavior control and all references to it become invalid. This is an asynchronous operation. Use the <code>GetPolicy</code> operation to poll the <code>status</code> field to track completion.</p>

    Args:
        policy_engine_id: <p>The identifier of the policy engine that manages the policy to be deleted. This ensures the policy is deleted from the correct policy engine context.</p>
        policy_id: <p>The unique identifier of the policy to be deleted. This must be a valid policy ID that exists within the specified policy engine.</p>

    Raises:
        capo_bedrock_agentcore_control.errors.access_denied_exception.AccessDeniedException: <p>This exception is thrown when a request is denied per access permissions</p>
        capo_bedrock_agentcore_control.errors.conflict_exception.ConflictException: <p>This exception is thrown when there is a conflict performing an operation</p>
        capo_bedrock_agentcore_control.errors.internal_server_exception.InternalServerException: <p>This exception is thrown if there was an unexpected error during processing of request</p>
        capo_bedrock_agentcore_control.errors.resource_not_found_exception.ResourceNotFoundException: <p>This exception is thrown when a resource referenced by the operation does not exist</p>
        capo_bedrock_agentcore_control.errors.throttling_exception.ThrottlingException: <p>This exception is thrown when the number of requests exceeds the limit</p>
        capo_bedrock_agentcore_control.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by the service.</p>
        capo_bedrock_agentcore_control.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_bedrock_agentcore_control.types.delete_policy_request.DeletePolicyRequest]",
    ) -> OperationResponse[
        "capo_bedrock_agentcore_control.types.delete_policy_response.DeletePolicyResponse"
    ]:
        import capo_bedrock_agentcore_control._operations.amazon_bedrock_agent_core_control.delete_policy

        output, http_response = (
            capo_bedrock_agentcore_control._operations.amazon_bedrock_agent_core_control.delete_policy.delete_policy(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_bedrock_agentcore_control.types.delete_policy_response.DeletePolicyResponse",
    ) -> dict[str, Any]:
        import capo_bedrock_agentcore_control.types.delete_policy_response

        return capo_bedrock_agentcore_control.types.delete_policy_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("DeletePolicy", redact_output=_redact_output),
    )
    input_: capo_bedrock_agentcore_control.types.delete_policy_request.DeletePolicyRequest = {
        "policy_engine_id": policy_engine_id,
        "policy_id": policy_id,
    }

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