createThesaurus method

Future<CreateThesaurusResponse> createThesaurus({
  1. required String indexId,
  2. required String name,
  3. required String roleArn,
  4. required S3Path sourceS3Path,
  5. String? clientToken,
  6. String? description,
  7. List<Tag>? tags,
})

Creates a thesaurus for an index. The thesaurus contains a list of synonyms in Solr format.

For an example of adding a thesaurus file to an index, see Adding custom synonyms to an index.

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

Parameter indexId : The identifier of the index for the thesaurus.

Parameter name : A name for the thesaurus.

Parameter roleArn : The Amazon Resource Name (ARN) of an IAM role with permission to access your S3 bucket that contains the thesaurus file. For more information, see IAM access roles for Amazon Kendra.

Parameter sourceS3Path : The path to the thesaurus file in S3.

Parameter clientToken : A token that you provide to identify the request to create a thesaurus. Multiple calls to the CreateThesaurus API with the same client token will create only one thesaurus.

Parameter description : A description for the thesaurus.

Parameter tags : A list of key-value pairs that identify or categorize the thesaurus. You can also use tags to help control access to the thesaurus. Tag keys and values can consist of Unicode letters, digits, white space, and any of the following symbols: _ . : / = + - @.

Implementation

Future<CreateThesaurusResponse> createThesaurus({
  required String indexId,
  required String name,
  required String roleArn,
  required S3Path sourceS3Path,
  String? clientToken,
  String? description,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSKendraFrontendService.CreateThesaurus'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'IndexId': indexId,
      'Name': name,
      'RoleArn': roleArn,
      'SourceS3Path': sourceS3Path,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (description != null) 'Description': description,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateThesaurusResponse.fromJson(jsonResponse.body);
}