getDiscoveredResourceCounts method

Future<GetDiscoveredResourceCountsResponse> getDiscoveredResourceCounts({
  1. int? limit,
  2. String? nextToken,
  3. List<String>? resourceTypes,
})

Returns the resource types, the number of each resource type, and the total number of resources that AWS Config is recording in this region for your AWS account.

Example

  1. AWS Config is recording three resource types in the US East (Ohio) Region for your account: 25 EC2 instances, 20 IAM users, and 15 S3 buckets.
  2. You make a call to the GetDiscoveredResourceCounts action and specify that you want all resource types.
  3. AWS Config returns the following:
    • The resource types (EC2 instances, IAM users, and S3 buckets).
    • The number of each resource type (25, 20, and 15).
    • The total number of all resources (60).
The response is paginated. By default, AWS Config lists 100 ResourceCount objects on each page. You can customize this number with the limit parameter. The response includes a nextToken string. To get the next page of results, run the request again and specify the string for the nextToken parameter.

May throw ValidationException. May throw InvalidLimitException. May throw InvalidNextTokenException.

Parameter limit : The maximum number of ResourceCount objects returned on each page. The default is 100. You cannot specify a number greater than 100. If you specify 0, AWS Config uses the default.

Parameter nextToken : The nextToken string returned on a previous page that you use to get the next page of results in a paginated response.

Parameter resourceTypes : The comma-separated list that specifies the resource types that you want AWS Config to return (for example, "AWS::EC2::Instance", "AWS::IAM::User").

If a value for resourceTypes is not specified, AWS Config returns all resource types that AWS Config is recording in the region for your account.

Implementation

Future<GetDiscoveredResourceCountsResponse> getDiscoveredResourceCounts({
  int? limit,
  String? nextToken,
  List<String>? resourceTypes,
}) async {
  _s.validateNumRange(
    'limit',
    limit,
    0,
    100,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'StarlingDoveService.GetDiscoveredResourceCounts'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (limit != null) 'limit': limit,
      if (nextToken != null) 'nextToken': nextToken,
      if (resourceTypes != null) 'resourceTypes': resourceTypes,
    },
  );

  return GetDiscoveredResourceCountsResponse.fromJson(jsonResponse.body);
}