listCollections method

Future<ListCollectionsResponse> listCollections({
  1. int? maxResults,
  2. String? nextToken,
})

Returns list of collection IDs in your account. If the result is truncated, the response also provides a NextToken that you can use in the subsequent request to fetch the next set of collection IDs.

For an example, see Listing Collections in the Amazon Rekognition Developer Guide.

This operation requires permissions to perform the rekognition:ListCollections action.

May throw InvalidParameterException. May throw AccessDeniedException. May throw InternalServerError. May throw ThrottlingException. May throw ProvisionedThroughputExceededException. May throw InvalidPaginationTokenException. May throw ResourceNotFoundException.

Parameter maxResults : Maximum number of collection IDs to return.

Parameter nextToken : Pagination token from the previous response.

Implementation

Future<ListCollectionsResponse> listCollections({
  int? maxResults,
  String? nextToken,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    0,
    4096,
  );
  _s.validateStringLength(
    'nextToken',
    nextToken,
    0,
    255,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'RekognitionService.ListCollections'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (maxResults != null) 'MaxResults': maxResults,
      if (nextToken != null) 'NextToken': nextToken,
    },
  );

  return ListCollectionsResponse.fromJson(jsonResponse.body);
}