listClusters method

Future<ListClustersOutput> listClusters({
  1. List<ClusterState>? clusterStates,
  2. DateTime? createdAfter,
  3. DateTime? createdBefore,
  4. String? marker,
})

Provides the status of all clusters visible to this AWS account. Allows you to filter the list of clusters based on certain criteria; for example, filtering by cluster creation date and time or by status. This call returns a maximum of 50 clusters per call, but returns a marker to track the paging of the cluster list across multiple ListClusters calls.

May throw InternalServerException. May throw InvalidRequestException.

Parameter clusterStates : The cluster state filters to apply when listing clusters.

Parameter createdAfter : The creation date and time beginning value filter for listing clusters.

Parameter createdBefore : The creation date and time end value filter for listing clusters.

Parameter marker : The pagination token that indicates the next set of results to retrieve.

Implementation

Future<ListClustersOutput> listClusters({
  List<ClusterState>? clusterStates,
  DateTime? createdAfter,
  DateTime? createdBefore,
  String? marker,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'ElasticMapReduce.ListClusters'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (clusterStates != null)
        'ClusterStates': clusterStates.map((e) => e.toValue()).toList(),
      if (createdAfter != null)
        'CreatedAfter': unixTimestampToJson(createdAfter),
      if (createdBefore != null)
        'CreatedBefore': unixTimestampToJson(createdBefore),
      if (marker != null) 'Marker': marker,
    },
  );

  return ListClustersOutput.fromJson(jsonResponse.body);
}