createDataSource method

Future<CreateDataSourceResponse> createDataSource({
  1. required String applicationId,
  2. required Object configuration,
  3. required String displayName,
  4. required String indexId,
  5. String? clientToken,
  6. String? description,
  7. DocumentEnrichmentConfiguration? documentEnrichmentConfiguration,
  8. MediaExtractionConfiguration? mediaExtractionConfiguration,
  9. String? roleArn,
  10. String? syncSchedule,
  11. List<Tag>? tags,
  12. DataSourceVpcConfiguration? vpcConfiguration,
})

Creates a data source connector for an Amazon Q Business application.

CreateDataSource is a synchronous operation. The operation returns 200 if the data source was successfully created. Otherwise, an exception is raised.

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

Parameter applicationId : The identifier of the Amazon Q Business application the data source will be attached to.

Parameter configuration : Configuration information to connect your data source repository to Amazon Q Business. Use this parameter to provide a JSON schema with configuration information specific to your data source connector.

Each data source has a JSON schema provided by Amazon Q Business that you must use. For example, the Amazon S3 and Web Crawler connectors require the following JSON schemas:

You can find configuration templates for your specific data source using the following steps:
  1. Navigate to the Supported connectors page in the Amazon Q Business User Guide, and select the data source of your choice.
  2. Then, from your specific data source connector page, select Using the API. You will find the JSON schema for your data source, including parameter descriptions, in this section.

Parameter displayName : A name for the data source connector.

Parameter indexId : The identifier of the index that you want to use with the data source connector.

Parameter clientToken : A token you provide to identify a request to create a data source connector. Multiple calls to the CreateDataSource API with the same client token will create only one data source connector.

Parameter description : A description for the data source connector.

Parameter mediaExtractionConfiguration : The configuration for extracting information from media in documents during ingestion.

Parameter roleArn : The Amazon Resource Name (ARN) of an IAM role with permission to access the data source and required resources. This field is required for all connector types except custom connectors, where it is optional.

Parameter syncSchedule : Sets the frequency for Amazon Q Business to check the documents in your data source repository and update your index. If you don't set a schedule, Amazon Q Business won't periodically update the index.

Specify a cron- format schedule string or an empty string to indicate that the index is updated on demand. You can't specify the Schedule parameter when the Type parameter is set to CUSTOM. If you do, you receive a ValidationException exception.

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

Parameter vpcConfiguration : Configuration information for an Amazon VPC (Virtual Private Cloud) to connect to your data source. For more information, see Using Amazon VPC with Amazon Q Business connectors.

Implementation

Future<CreateDataSourceResponse> createDataSource({
  required String applicationId,
  required Object configuration,
  required String displayName,
  required String indexId,
  String? clientToken,
  String? description,
  DocumentEnrichmentConfiguration? documentEnrichmentConfiguration,
  MediaExtractionConfiguration? mediaExtractionConfiguration,
  String? roleArn,
  String? syncSchedule,
  List<Tag>? tags,
  DataSourceVpcConfiguration? vpcConfiguration,
}) async {
  final $payload = <String, dynamic>{
    'configuration': configuration,
    'displayName': displayName,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (description != null) 'description': description,
    if (documentEnrichmentConfiguration != null)
      'documentEnrichmentConfiguration': documentEnrichmentConfiguration,
    if (mediaExtractionConfiguration != null)
      'mediaExtractionConfiguration': mediaExtractionConfiguration,
    if (roleArn != null) 'roleArn': roleArn,
    if (syncSchedule != null) 'syncSchedule': syncSchedule,
    if (tags != null) 'tags': tags,
    if (vpcConfiguration != null) 'vpcConfiguration': vpcConfiguration,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/applications/${Uri.encodeComponent(applicationId)}/indices/${Uri.encodeComponent(indexId)}/datasources',
    exceptionFnMap: _exceptionFns,
  );
  return CreateDataSourceResponse.fromJson(response);
}