updateVocabulary method

Future<UpdateVocabularyResponse> updateVocabulary({
  1. required LanguageCode languageCode,
  2. required String vocabularyName,
  3. List<String>? phrases,
  4. String? vocabularyFileUri,
})

Updates an existing vocabulary with new values. The UpdateVocabulary operation overwrites all of the existing information with the values that you provide in the request.

May throw BadRequestException. May throw LimitExceededException. May throw InternalFailureException. May throw NotFoundException. May throw ConflictException.

Parameter languageCode : The language code of the vocabulary entries.

Parameter vocabularyName : The name of the vocabulary to update. The name is case sensitive. If you try to update a vocabulary with the same name as a previous vocabulary you will receive a ConflictException error.

Parameter phrases : An array of strings containing the vocabulary entries.

Parameter vocabularyFileUri : The S3 location of the text file that contains the definition of the custom vocabulary. The URI must be in the same region as the API endpoint that you are calling. The general form is

For example:

For more information about S3 object names, see Object Keys in the Amazon S3 Developer Guide.

For more information about custom vocabularies, see Custom Vocabularies.

Implementation

Future<UpdateVocabularyResponse> updateVocabulary({
  required LanguageCode languageCode,
  required String vocabularyName,
  List<String>? phrases,
  String? vocabularyFileUri,
}) async {
  ArgumentError.checkNotNull(languageCode, 'languageCode');
  ArgumentError.checkNotNull(vocabularyName, 'vocabularyName');
  _s.validateStringLength(
    'vocabularyName',
    vocabularyName,
    1,
    200,
    isRequired: true,
  );
  _s.validateStringLength(
    'vocabularyFileUri',
    vocabularyFileUri,
    1,
    2000,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Transcribe.UpdateVocabulary'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'LanguageCode': languageCode.toValue(),
      'VocabularyName': vocabularyName,
      if (phrases != null) 'Phrases': phrases,
      if (vocabularyFileUri != null) 'VocabularyFileUri': vocabularyFileUri,
    },
  );

  return UpdateVocabularyResponse.fromJson(jsonResponse.body);
}