createIndex method

Future<CreateIndexResponse> createIndex({
  1. required String name,
  2. required String roleArn,
  3. String? clientToken,
  4. String? description,
  5. IndexEdition? edition,
  6. ServerSideEncryptionConfiguration? serverSideEncryptionConfiguration,
  7. List<Tag>? tags,
  8. UserContextPolicy? userContextPolicy,
  9. List<UserTokenConfiguration>? userTokenConfigurations,
})

Creates a new Amazon Kendra index. Index creation is an asynchronous operation. To determine if index creation has completed, check the Status field returned from a call to . The Status field is set to ACTIVE when the index is ready to use.

Once the index is active you can index your documents using the operation or using one of the supported data sources.

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

Parameter name : The name for the new index.

Parameter roleArn : An AWS Identity and Access Management (IAM) role that gives Amazon Kendra permissions to access your Amazon CloudWatch logs and metrics. This is also the role used when you use the BatchPutDocument operation to index documents from an Amazon S3 bucket.

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

Parameter description : A description for the index.

Parameter edition : The Amazon Kendra edition to use for the index. Choose DEVELOPER_EDITION for indexes intended for development, testing, or proof of concept. Use ENTERPRISE_EDITION for your production databases. Once you set the edition for an index, it can't be changed.

The Edition parameter is optional. If you don't supply a value, the default is ENTERPRISE_EDITION.

Parameter serverSideEncryptionConfiguration : The identifier of the AWS KMS customer managed key (CMK) to use to encrypt data indexed by Amazon Kendra. Amazon Kendra doesn't support asymmetric CMKs.

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

Parameter userContextPolicy : The user context policy.

ATTRIBUTE_FILTER
All indexed content is searchable and displayable for all users. If there is an access control list, it is ignored. You can filter on user and group attributes.
USER_TOKEN
Enables SSO and token-based user access control. All documents with no access control and all documents accessible to the user will be searchable and displayable.

Parameter userTokenConfigurations : The user token configuration.

Implementation

Future<CreateIndexResponse> createIndex({
  required String name,
  required String roleArn,
  String? clientToken,
  String? description,
  IndexEdition? edition,
  ServerSideEncryptionConfiguration? serverSideEncryptionConfiguration,
  List<Tag>? tags,
  UserContextPolicy? userContextPolicy,
  List<UserTokenConfiguration>? userTokenConfigurations,
}) async {
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    1000,
    isRequired: true,
  );
  ArgumentError.checkNotNull(roleArn, 'roleArn');
  _s.validateStringLength(
    'roleArn',
    roleArn,
    1,
    1284,
    isRequired: true,
  );
  _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.CreateIndex'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      'RoleArn': roleArn,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (description != null) 'Description': description,
      if (edition != null) 'Edition': edition.toValue(),
      if (serverSideEncryptionConfiguration != null)
        'ServerSideEncryptionConfiguration':
            serverSideEncryptionConfiguration,
      if (tags != null) 'Tags': tags,
      if (userContextPolicy != null)
        'UserContextPolicy': userContextPolicy.toValue(),
      if (userTokenConfigurations != null)
        'UserTokenConfigurations': userTokenConfigurations,
    },
  );

  return CreateIndexResponse.fromJson(jsonResponse.body);
}