createCollection method
Creates a new OpenSearch Serverless collection. For more information, see Creating and managing Amazon OpenSearch Serverless collections.
May throw ConflictException.
May throw InternalServerException.
May throw OcuLimitExceededException.
May throw ServiceQuotaExceededException.
May throw ValidationException.
Parameter name :
Name of the collection.
Parameter clientToken :
Unique, case-sensitive identifier to ensure idempotency of the request.
Parameter collectionGroupName :
The name of the collection group to associate with the collection.
Parameter deletionProtection :
Indicates whether to enable deletion protection for the collection. When
set to ENABLED, the collection cannot be deleted.
Parameter description :
Description of the collection.
Parameter encryptionConfig :
Encryption settings for the collection.
Parameter standbyReplicas :
Indicates whether standby replicas should be used for a collection.
Parameter tags :
An arbitrary set of tags (key–value pairs) to associate with the
OpenSearch Serverless collection.
Parameter type :
The type of collection.
Parameter vectorOptions :
Configuration options for vector search capabilities in the collection.
Implementation
Future<CreateCollectionResponse> createCollection({
required String name,
String? clientToken,
String? collectionGroupName,
DeletionProtection? deletionProtection,
String? description,
EncryptionConfig? encryptionConfig,
StandbyReplicas? standbyReplicas,
List<Tag>? tags,
CollectionType? type,
VectorOptions? vectorOptions,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'OpenSearchServerless.CreateCollection'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'name': name,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (collectionGroupName != null)
'collectionGroupName': collectionGroupName,
if (deletionProtection != null)
'deletionProtection': deletionProtection.value,
if (description != null) 'description': description,
if (encryptionConfig != null) 'encryptionConfig': encryptionConfig,
if (standbyReplicas != null) 'standbyReplicas': standbyReplicas.value,
if (tags != null) 'tags': tags,
if (type != null) 'type': type.value,
if (vectorOptions != null) 'vectorOptions': vectorOptions,
},
);
return CreateCollectionResponse.fromJson(jsonResponse.body);
}