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.

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

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

Parameter name : The name for the new thesaurus.

Parameter roleArn : An AWS Identity and Access Management (IAM) role that gives Amazon Kendra permissions to access thesaurus file specified in SourceS3Path.

Parameter sourceS3Path : The thesaurus file Amazon S3 source path.

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

Parameter description : The description for the new thesaurus.

Parameter tags : A list of key-value pairs that identify the thesaurus. You can use the tags to identify and organize your resources and to control access to resources.

Implementation

Future<CreateThesaurusResponse> createThesaurus({
  required String indexId,
  required String name,
  required String roleArn,
  required S3Path sourceS3Path,
  String? clientToken,
  String? description,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(indexId, 'indexId');
  _s.validateStringLength(
    'indexId',
    indexId,
    36,
    36,
    isRequired: true,
  );
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    100,
    isRequired: true,
  );
  ArgumentError.checkNotNull(roleArn, 'roleArn');
  _s.validateStringLength(
    'roleArn',
    roleArn,
    1,
    1284,
    isRequired: true,
  );
  ArgumentError.checkNotNull(sourceS3Path, 'sourceS3Path');
  _s.validateStringLength(
    'clientToken',
    clientToken,
    1,
    100,
  );
  _s.validateStringLength(
    'description',
    description,
    0,
    1000,
  );
  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);
}