createVocabulary method

Future<CreateVocabularyResponse> createVocabulary({
  1. required String content,
  2. required String instanceId,
  3. required VocabularyLanguageCode languageCode,
  4. required String vocabularyName,
  5. String? clientToken,
  6. Map<String, String>? tags,
})

Creates a custom vocabulary associated with your Connect Customer instance. You can set a custom vocabulary to be your default vocabulary for a given language. Contact Lens for Connect Customer uses the default vocabulary in post-call and real-time contact analysis sessions for that language.

May throw AccessDeniedException. May throw InternalServiceException. May throw InvalidRequestException. May throw ResourceConflictException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException.

Parameter content : The content of the custom vocabulary in plain-text format with a table of values. Each row in the table represents a word or a phrase, described with Phrase, IPA, SoundsLike, and DisplayAs fields. Separate the fields with TAB characters. The size limit is 50KB. For more information, see Create a custom vocabulary using a table.

Parameter instanceId : The identifier of the Connect Customer instance. You can find the instance ID in the Amazon Resource Name (ARN) of the instance.

Parameter languageCode : The language code of the vocabulary entries. For a list of languages and their corresponding language codes, see What is Amazon Transcribe?

Parameter vocabularyName : A unique name of the custom vocabulary.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs. If a create request is received more than once with same client token, subsequent requests return the previous response without creating a vocabulary again.

Parameter tags : The tags used to organize, track, or control access for this resource. For example, { "Tags": {"key1":"value1", "key2":"value2"} }.

Implementation

Future<CreateVocabularyResponse> createVocabulary({
  required String content,
  required String instanceId,
  required VocabularyLanguageCode languageCode,
  required String vocabularyName,
  String? clientToken,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'Content': content,
    'LanguageCode': languageCode.value,
    'VocabularyName': vocabularyName,
    'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (tags != null) 'Tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/vocabulary/${Uri.encodeComponent(instanceId)}',
    exceptionFnMap: _exceptionFns,
  );
  return CreateVocabularyResponse.fromJson(response);
}