createFaq method

Future<CreateFaqResponse> createFaq({
  1. required String indexId,
  2. required String name,
  3. required String roleArn,
  4. required S3Path s3Path,
  5. String? clientToken,
  6. String? description,
  7. FaqFileFormat? fileFormat,
  8. List<Tag>? tags,
})

Creates an new set of frequently asked question (FAQ) questions and answers.

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

Parameter indexId : The identifier of the index that contains the FAQ.

Parameter name : The name that should be associated with the FAQ.

Parameter roleArn : The Amazon Resource Name (ARN) of a role with permission to access the S3 bucket that contains the FAQs. For more information, see IAM Roles for Amazon Kendra.

Parameter s3Path : The S3 location of the FAQ input data.

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

Parameter description : A description of the FAQ.

Parameter fileFormat : The format of the input file. You can choose between a basic CSV format, a CSV format that includes customs attributes in a header, and a JSON format that includes custom attributes.

The format must match the format of the file stored in the S3 bucket identified in the S3Path parameter.

For more information, see Adding questions and answers.

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

Implementation

Future<CreateFaqResponse> createFaq({
  required String indexId,
  required String name,
  required String roleArn,
  required S3Path s3Path,
  String? clientToken,
  String? description,
  FaqFileFormat? fileFormat,
  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(s3Path, 's3Path');
  _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.CreateFaq'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'IndexId': indexId,
      'Name': name,
      'RoleArn': roleArn,
      'S3Path': s3Path,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (description != null) 'Description': description,
      if (fileFormat != null) 'FileFormat': fileFormat.toValue(),
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateFaqResponse.fromJson(jsonResponse.body);
}