createTable method
Future<CreateTableOutput>
createTable({
- required KeySchema keySchema,
- required ProvisionedThroughput provisionedThroughput,
- required String tableName,
Adds a new table to your account.
The table name must be unique among those associated with the AWS Account
issuing the request, and the AWS Region that receives the request (e.g.
us-east-1
).
The CreateTable
operation triggers an asynchronous workflow
to begin creating the table. Amazon DynamoDB immediately returns the state
of the table (CREATING
) until the table is in the
ACTIVE
state. Once the table is in the ACTIVE
state, you can perform data plane operations.
May throw ResourceInUseException. May throw LimitExceededException. May throw InternalServerError.
Parameter tableName
:
The name of the table you want to create. Allowed characters are
a-z
, A-Z
, 0-9
, _
(underscore), -
(hyphen) and .
(period).
Implementation
Future<CreateTableOutput> createTable({
required KeySchema keySchema,
required ProvisionedThroughput provisionedThroughput,
required String tableName,
}) async {
ArgumentError.checkNotNull(keySchema, 'keySchema');
ArgumentError.checkNotNull(provisionedThroughput, 'provisionedThroughput');
ArgumentError.checkNotNull(tableName, 'tableName');
_s.validateStringLength(
'tableName',
tableName,
3,
255,
isRequired: true,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'DynamoDB_20111205.CreateTable'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'KeySchema': keySchema,
'ProvisionedThroughput': provisionedThroughput,
'TableName': tableName,
},
);
return CreateTableOutput.fromJson(jsonResponse.body);
}