updateCollection method

Future<UpdateCollectionResponse> updateCollection({
  1. required String id,
  2. String? clientToken,
  3. DeletionProtection? deletionProtection,
  4. String? description,
  5. VectorOptions? vectorOptions,
})

Updates an OpenSearch Serverless collection.

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

Parameter id : The unique identifier of the collection.

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

Parameter deletionProtection : Indicates whether to enable or disable deletion protection for the collection. When set to ENABLED, the collection cannot be deleted.

Parameter description : A description of the collection.

Parameter vectorOptions : Configuration options for vector search capabilities in the collection.

Implementation

Future<UpdateCollectionResponse> updateCollection({
  required String id,
  String? clientToken,
  DeletionProtection? deletionProtection,
  String? description,
  VectorOptions? vectorOptions,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'OpenSearchServerless.UpdateCollection'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'id': id,
      'clientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (deletionProtection != null)
        'deletionProtection': deletionProtection.value,
      if (description != null) 'description': description,
      if (vectorOptions != null) 'vectorOptions': vectorOptions,
    },
  );

  return UpdateCollectionResponse.fromJson(jsonResponse.body);
}