describeAccountPolicies method

Future<DescribeAccountPoliciesResponse> describeAccountPolicies({
  1. required PolicyType policyType,
  2. List<String>? accountIdentifiers,
  3. String? nextToken,
  4. String? policyName,
})

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.

May throw InvalidParameterException. May throw OperationAbortedException. May throw ResourceNotFoundException. May throw ServiceUnavailableException.

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

Parameter accountIdentifiers : 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.

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

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

Implementation

Future<DescribeAccountPoliciesResponse> describeAccountPolicies({
  required PolicyType policyType,
  List<String>? accountIdentifiers,
  String? nextToken,
  String? policyName,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Logs_20140328.DescribeAccountPolicies'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'policyType': policyType.value,
      if (accountIdentifiers != null)
        'accountIdentifiers': accountIdentifiers,
      if (nextToken != null) 'nextToken': nextToken,
      if (policyName != null) 'policyName': policyName,
    },
  );

  return DescribeAccountPoliciesResponse.fromJson(jsonResponse.body);
}