addDatasetExamples method

Future<AddDatasetExamplesResponse> addDatasetExamples({
  1. required String datasetId,
  2. required DataSourceType source,
  3. String? clientToken,
})

Adds examples to the dataset's DRAFT. All examples are validated against the dataset's schema type before any writes occur. If any example fails validation, the entire batch is rejected (all-or-nothing semantics).

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

Parameter datasetId : The unique identifier of the dataset to add examples to.

Parameter source : Source of examples to add. 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.

Implementation

Future<AddDatasetExamplesResponse> addDatasetExamples({
  required String datasetId,
  required DataSourceType source,
  String? clientToken,
}) async {
  final $payload = <String, dynamic>{
    'source': source,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/datasets/${Uri.encodeComponent(datasetId)}/examples/add',
    exceptionFnMap: _exceptionFns,
  );
  return AddDatasetExamplesResponse.fromJson(response);
}