listFaces method

Future<ListFacesResponse> listFaces({
  1. required String collectionId,
  2. int? maxResults,
  3. String? nextToken,
})

Returns metadata for faces in the specified collection. This metadata includes information such as the bounding box coordinates, the confidence (that the bounding box contains a face), and face ID. For an example, see Listing Faces in a Collection in the Amazon Rekognition Developer Guide.

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

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

Parameter collectionId : ID of the collection from which to list the faces.

Parameter maxResults : Maximum number of faces to return.

Parameter nextToken : If the previous response was incomplete (because there is more data to retrieve), Amazon Rekognition returns a pagination token in the response. You can use this pagination token to retrieve the next set of faces.

Implementation

Future<ListFacesResponse> listFaces({
  required String collectionId,
  int? maxResults,
  String? nextToken,
}) async {
  ArgumentError.checkNotNull(collectionId, 'collectionId');
  _s.validateStringLength(
    'collectionId',
    collectionId,
    1,
    255,
    isRequired: true,
  );
  _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.ListFaces'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'CollectionId': collectionId,
      if (maxResults != null) 'MaxResults': maxResults,
      if (nextToken != null) 'NextToken': nextToken,
    },
  );

  return ListFacesResponse.fromJson(jsonResponse.body);
}