deleteCollection method

Future<DeleteCollectionResponse> deleteCollection({
  1. required String id,
  2. String? clientToken,
})

Deletes an OpenSearch Serverless collection. For more information, see Creating and managing Amazon OpenSearch Serverless collections.

May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ValidationException.

Parameter id : The unique identifier of the collection. For example, 1iu5usc406kd. The ID is part of the collection endpoint. You can also retrieve it using the ListCollections API.

Parameter clientToken : A unique, case-sensitive identifier to ensure idempotency of the request.

Implementation

Future<DeleteCollectionResponse> deleteCollection({
  required String id,
  String? clientToken,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'OpenSearchServerless.DeleteCollection'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'id': id,
      'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    },
  );

  return DeleteCollectionResponse.fromJson(jsonResponse.body);
}