Skip to content

delete_agent_enforced_policy async

delete_agent_enforced_policy(
    policy_id: AgentEnforcedPolicyId,
    *,
    config_overrides: Optional[AsyncWorkSpacesClientConfig] = None,
) -> DeleteAgentEnforcedPolicyResult

Deletes an agent-enforced policy that you created. You can't undo this action. You can't delete a policy that Amazon owns. If you try, the operation returns ValidationException. You can't delete a policy that a persona configuration or a WorkSpace uses. If you try, the operation returns ConflictException, and its ResourceId identifies a persona configuration or WorkSpace that uses the policy.

Parameters:

Raises:

  • AccessDeniedException –

    The user is not authorized to access a resource.

  • ConflictException –

    The request conflicts with the current state of a resource, for example because a name is already in use or the resource is still in use. Resolve the conflict, and then retry your request.

  • ResourceNotFoundException –

    The resource could not be found.

  • ThrottlingException –

    The request was throttled. Retry the request with exponential backoff.

  • ValidationException –

    Your request failed validation. Check the error message for the parameter that isn't valid.

  • UnknownServiceError –

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

Examples:

Example – Deleting an agent-enforced policy The following example deletes an agent-enforced policy.

>>> await client.delete_agent_enforced_policy(policy_id='wsae-a1b2c3d4')
Source code in docs_src/capo_workspaces/_services/async_work_spaces.py
async def delete_agent_enforced_policy(
    self,
    policy_id: "capo_workspaces.types.agent_enforced_policy_id.AgentEnforcedPolicyId",
    *,
    config_overrides: Optional[AsyncWorkSpacesClientConfig] = None,
) -> "capo_workspaces.types.delete_agent_enforced_policy_result.DeleteAgentEnforcedPolicyResult":
    """<p>Deletes an agent-enforced policy that you created. You can't undo this action. You can't delete a policy that Amazon owns. If you try, the operation returns <code>ValidationException</code>. You can't delete a policy that a persona configuration or a WorkSpace uses. If you try, the operation returns <code>ConflictException</code>, and its <code>ResourceId</code> identifies a persona configuration or WorkSpace that uses the policy.</p>

    Args:
        policy_id: <p>The identifier of the policy.</p>

    Raises:
        capo_workspaces.errors.access_denied_exception.AccessDeniedException: <p>The user is not authorized to access a resource.</p>
        capo_workspaces.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of a resource, for example because a name is already in use or the resource is still in use. Resolve the conflict, and then retry your request.</p>
        capo_workspaces.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource could not be found.</p>
        capo_workspaces.errors.throttling_exception.ThrottlingException: <p>The request was throttled. Retry the request with exponential backoff.</p>
        capo_workspaces.errors.validation_exception.ValidationException: <p>Your request failed validation. Check the error message for the parameter that isn't valid.</p>
        capo_workspaces.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Example – Deleting an agent-enforced policy
        The following example deletes an agent-enforced policy.

        >>> await client.delete_agent_enforced_policy(policy_id='wsae-a1b2c3d4')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_workspaces.types.delete_agent_enforced_policy_request.DeleteAgentEnforcedPolicyRequest]",
    ) -> AsyncOperationResponse[
        "capo_workspaces.types.delete_agent_enforced_policy_result.DeleteAgentEnforcedPolicyResult"
    ]:
        if req.options.protocol == "awsJson1_1":
            import capo_workspaces._operations.workspaces_service.aws_json1_1.delete_agent_enforced_policy

            (
                output,
                http_response,
            ) = await capo_workspaces._operations.workspaces_service.aws_json1_1.delete_agent_enforced_policy.async_delete_agent_enforced_policy(
                req.options, req.input
            )
        elif req.options.protocol == "rpcv2Cbor":
            import capo_workspaces._operations.workspaces_service.rpcv2_cbor.delete_agent_enforced_policy

            (
                output,
                http_response,
            ) = await capo_workspaces._operations.workspaces_service.rpcv2_cbor.delete_agent_enforced_policy.async_delete_agent_enforced_policy(
                req.options, req.input
            )
        else:
            raise ValueError(f"unknown protocol {req.options.protocol!r}")
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteAgentEnforcedPolicy")
    )
    input_: capo_workspaces.types.delete_agent_enforced_policy_request.DeleteAgentEnforcedPolicyRequest = {
        "policy_id": policy_id
    }

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