createDataset method
Creates a new dataset resource asynchronously. Returns immediately with
status CREATING. Poll GetDataset until status transitions to
ACTIVE or CREATE_FAILED.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter datasetName :
Human-readable name for the dataset. Must be unique within the account.
Immutable after creation.
Parameter schemaType :
Versioned schema type governing the structure of examples. Immutable after
creation.
Parameter source :
Source of initial examples. Provide either inline examples or an S3 URI
pointing to a JSONL file.
Parameter clientToken :
A unique, case-sensitive identifier to ensure that the API request
completes no more than one time. If you don't specify this field, a value
is randomly generated for you. If this token matches a previous request,
the service ignores the request, but doesn't return an error. For more
information, see Ensuring
idempotency.
Parameter description :
A description of the dataset.
Parameter kmsKeyArn :
Optional KMS key ARN for server-side encryption on service Amazon S3
writes.
Parameter tags :
A map of tag keys and values to assign to the dataset.
Implementation
Future<CreateDatasetResponse> createDataset({
required String datasetName,
required DatasetSchemaType schemaType,
required DataSourceType source,
String? clientToken,
String? description,
String? kmsKeyArn,
Map<String, String>? tags,
}) async {
final $payload = <String, dynamic>{
'datasetName': datasetName,
'schemaType': schemaType.value,
'source': source,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (description != null) 'description': description,
if (kmsKeyArn != null) 'kmsKeyArn': kmsKeyArn,
if (tags != null) 'tags': tags,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/datasets',
exceptionFnMap: _exceptionFns,
);
return CreateDatasetResponse.fromJson(response);
}