createCollection method

Future<CreateCollectionResponse> createCollection({
  1. required String collectionId,
})

Creates a collection in an AWS Region. You can add faces to the collection using the IndexFaces operation.

For example, you might create collections, one for each of your application users. A user can then index faces using the IndexFaces operation and persist results in a specific collection. Then, a user can search the collection for faces in the user-specific container.

When you create a collection, it is associated with the latest version of the face model version. This operation requires permissions to perform the rekognition:CreateCollection action.

May throw InvalidParameterException. May throw AccessDeniedException. May throw InternalServerError. May throw ThrottlingException. May throw ProvisionedThroughputExceededException. May throw ResourceAlreadyExistsException.

Parameter collectionId : ID for the collection that you are creating.

Implementation

Future<CreateCollectionResponse> createCollection({
  required String collectionId,
}) async {
  ArgumentError.checkNotNull(collectionId, 'collectionId');
  _s.validateStringLength(
    'collectionId',
    collectionId,
    1,
    255,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'RekognitionService.CreateCollection'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'CollectionId': collectionId,
    },
  );

  return CreateCollectionResponse.fromJson(jsonResponse.body);
}