updateDatasetExamples method

Future<UpdateDatasetExamplesResponse> updateDatasetExamples({
  1. required String datasetId,
  2. required List<Object> examples,
  3. String? clientToken,
})

Updates multiple existing examples in-place on DRAFT. Validation: All examples are validated against the dataset's schemaType before any writes occur. If any example fails validation, the entire batch is rejected with ValidationException — no examples are updated (all-or-nothing semantics). Asynchronous: Operates in-place on DRAFT. No version bump occurs. Use CreateDatasetVersion to publish DRAFT as a new numbered version. Fails with ResourceNotFoundException if any exampleId does not exist in DRAFT. To add new examples, use AddDatasetExamples instead. State guard: Returns ConflictException (DATASET_NOT_READY) if the dataset status is not in {DRAFT, ACTIVE}. Request size limit: Max 5 MB total request body. Max 1000 examples per call.

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.

Parameter examples : Examples to update. Each element is a JSON object containing a required exampleId string field identifying the existing example, plus the replacement fields. The exampleId is extracted and removed before persistence; the remaining document is validated against the dataset's schemaType. Max 1000 examples per call. Total request body must not exceed 5 MB.

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<UpdateDatasetExamplesResponse> updateDatasetExamples({
  required String datasetId,
  required List<Object> examples,
  String? clientToken,
}) async {
  final $payload = <String, dynamic>{
    'examples': examples,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/datasets/${Uri.encodeComponent(datasetId)}/examples/update',
    exceptionFnMap: _exceptionFns,
  );
  return UpdateDatasetExamplesResponse.fromJson(response);
}