createKeyspace method

Future<CreateKeyspaceResponse> createKeyspace({
  1. required String keyspaceName,
  2. ReplicationSpecification? replicationSpecification,
  3. List<Tag>? tags,
})

The CreateKeyspace operation adds a new keyspace to your account. In an Amazon Web Services account, keyspace names must be unique within each Region.

CreateKeyspace is an asynchronous operation. You can monitor the creation status of the new keyspace by using the GetKeyspace operation.

For more information, see Create a keyspace in the Amazon Keyspaces Developer Guide.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ServiceQuotaExceededException. May throw ValidationException.

Parameter keyspaceName : The name of the keyspace to be created.

Parameter replicationSpecification : The replication specification of the keyspace includes:

  • replicationStrategy - the required value is SINGLE_REGION or MULTI_REGION.
  • regionList - if the replicationStrategy is MULTI_REGION, the regionList requires the current Region and at least one additional Amazon Web Services Region where the keyspace is going to be replicated in.

Parameter tags : A list of key-value pair tags to be attached to the keyspace.

For more information, see Adding tags and labels to Amazon Keyspaces resources in the Amazon Keyspaces Developer Guide.

Implementation

Future<CreateKeyspaceResponse> createKeyspace({
  required String keyspaceName,
  ReplicationSpecification? replicationSpecification,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'KeyspacesService.CreateKeyspace'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'keyspaceName': keyspaceName,
      if (replicationSpecification != null)
        'replicationSpecification': replicationSpecification,
      if (tags != null) 'tags': tags,
    },
  );

  return CreateKeyspaceResponse.fromJson(jsonResponse.body);
}