Skip to content

describe_account_policies

describe_account_policies(
    policy_type: PolicyType,
    *,
    config_overrides: Optional[CloudWatchLogsClientConfig] = None,
    policy_name: Optional[PolicyName] = None,
    account_identifiers: Optional[AccountIds] = None,
    next_token: Optional[NextToken] = None,
) -> DescribeAccountPoliciesResponse

Returns a list of all CloudWatch Logs account policies in the account.

To use this operation, you must be signed on with the correct permissions depending on the type of policy that you are retrieving information for.

  • To see data protection policies, you must have the logs:GetDataProtectionPolicy and logs:DescribeAccountPolicies permissions.

  • To see subscription filter policies, you must have the logs:DescribeSubscriptionFilters and logs:DescribeAccountPolicies permissions.

  • To see transformer policies, you must have the logs:GetTransformer and logs:DescribeAccountPolicies permissions.

  • To see field index policies, you must have the logs:DescribeIndexPolicies and logs:DescribeAccountPolicies permissions.

Parameters:

  • policy_type (PolicyType) –

    Use this parameter to limit the returned policies to only the policies that match the policy type that you specify.

  • policy_name (Optional[PolicyName], default: None ) –

    Use this parameter to limit the returned policies to only the policy with the name that you specify.

  • account_identifiers (Optional[AccountIds], default: None ) –

    If you are using an account that is set up as a monitoring account for CloudWatch unified cross-account observability, you can use this to specify the account ID of a source account. If you do, the operation returns the account policy for the specified account. Currently, you can specify only one account ID in this parameter.

    If you omit this parameter, only the policy in the current account is returned.

  • next_token (Optional[NextToken], default: None ) –

    The token for the next set of items to return. (You received this token from a previous call.)

Raises:

Source code in docs_src/capo_cloudwatch_logs/_services/cloud_watch_logs.py
def describe_account_policies(
    self,
    policy_type: "capo_cloudwatch_logs.types.policy_type.PolicyType",
    *,
    config_overrides: Optional[CloudWatchLogsClientConfig] = None,
    policy_name: Optional[
        "capo_cloudwatch_logs.types.policy_name.PolicyName"
    ] = None,
    account_identifiers: Optional[
        "capo_cloudwatch_logs.types.account_ids.AccountIds"
    ] = None,
    next_token: Optional["capo_cloudwatch_logs.types.next_token.NextToken"] = None,
) -> "capo_cloudwatch_logs.types.describe_account_policies_response.DescribeAccountPoliciesResponse":
    """<p>Returns a list of all CloudWatch Logs account policies in the account.</p> <p>To use this operation, you must be signed on with the correct permissions depending on the type of policy that you are retrieving information for.</p> <ul> <li> <p>To see data protection policies, you must have the <code>logs:GetDataProtectionPolicy</code> and <code>logs:DescribeAccountPolicies</code> permissions.</p> </li> <li> <p>To see subscription filter policies, you must have the <code>logs:DescribeSubscriptionFilters</code> and <code>logs:DescribeAccountPolicies</code> permissions.</p> </li> <li> <p>To see transformer policies, you must have the <code>logs:GetTransformer</code> and <code>logs:DescribeAccountPolicies</code> permissions.</p> </li> <li> <p>To see field index policies, you must have the <code>logs:DescribeIndexPolicies</code> and <code>logs:DescribeAccountPolicies</code> permissions.</p> </li> </ul>

    Args:
        policy_type: <p>Use this parameter to limit the returned policies to only the policies that match the policy type that you specify.</p>
        policy_name: <p>Use this parameter to limit the returned policies to only the policy with the name that you specify.</p>
        account_identifiers: <p>If you are using an account that is set up as a monitoring account for CloudWatch unified cross-account observability, you can use this to specify the account ID of a source account. If you do, the operation returns the account policy for the specified account. Currently, you can specify only one account ID in this parameter.</p> <p>If you omit this parameter, only the policy in the current account is returned.</p>
        next_token: <p>The token for the next set of items to return. (You received this token from a previous call.)</p>

    Raises:
        capo_cloudwatch_logs.errors.invalid_parameter_exception.InvalidParameterException: <p>A parameter is specified incorrectly.</p>
        capo_cloudwatch_logs.errors.operation_aborted_exception.OperationAbortedException: <p>Multiple concurrent requests to update the same resource were in conflict.</p>
        capo_cloudwatch_logs.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_cloudwatch_logs.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service cannot complete the request.</p>
        capo_cloudwatch_logs.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cloudwatch_logs.types.describe_account_policies_request.DescribeAccountPoliciesRequest]",
    ) -> OperationResponse[
        "capo_cloudwatch_logs.types.describe_account_policies_response.DescribeAccountPoliciesResponse"
    ]:
        import capo_cloudwatch_logs._operations.logs_20140328.describe_account_policies

        output, http_response = (
            capo_cloudwatch_logs._operations.logs_20140328.describe_account_policies.describe_account_policies(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DescribeAccountPolicies")
    )
    input_: capo_cloudwatch_logs.types.describe_account_policies_request.DescribeAccountPoliciesRequest = {
        "policy_type": policy_type
    }
    if policy_name is not None:
        input_["policy_name"] = policy_name
    if account_identifiers is not None:
        input_["account_identifiers"] = account_identifiers
    if next_token is not None:
        input_["next_token"] = next_token

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