Skip to content

create_data_source

create_data_source(
    application_id: ApplicationId,
    index_id: IndexId,
    display_name: DataSourceName,
    configuration: DataSourceConfiguration,
    *,
    config_overrides: Optional[QBusinessClientConfig] = None,
    vpc_configuration: Optional[DataSourceVpcConfiguration] = None,
    description: Optional[Description] = None,
    tags: Optional[Tags] = None,
    sync_schedule: Optional[SyncSchedule] = None,
    role_arn: Optional[RoleArn] = None,
    client_token: Optional[ClientToken] = None,
    document_enrichment_configuration: Optional[DocumentEnrichmentConfiguration] = None,
    media_extraction_configuration: Optional[MediaExtractionConfiguration] = None,
) -> CreateDataSourceResponse

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.

Parameters:

  • application_id (ApplicationId) –

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

  • index_id (IndexId) –

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

  • display_name (DataSourceName) –

    A name for the data source connector.

  • configuration (DataSourceConfiguration) –

    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.

  • vpc_configuration (Optional[DataSourceVpcConfiguration], default: None ) –

    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.

  • description (Optional[Description], default: None ) –

    A description for the data source connector.

  • tags (Optional[Tags], default: None ) –

    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: _ . : / = + - @.

  • sync_schedule (Optional[SyncSchedule], default: None ) –

    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.

  • role_arn (Optional[RoleArn], default: None ) –

    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.

  • client_token (Optional[ClientToken], default: None ) –

    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.

  • media_extraction_configuration (Optional[MediaExtractionConfiguration], default: None ) –

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

Raises:

  • AccessDeniedException –

    You don't have access to perform this action. Make sure you have the required permission policies and user accounts and try again.

  • ConflictException –

    You are trying to perform an action that conflicts with the current status of your resource. Fix any inconsistencies with your resources and try again.

  • InternalServerException –

    An issue occurred with the internal server used for your Amazon Q Business service. Wait some minutes and try again, or contact Support for help.

  • ResourceNotFoundException –

    The application or plugin resource you want to use doesn’t exist. Make sure you have provided the correct resource and try again.

  • ServiceQuotaExceededException –

    You have exceeded the set limits for your Amazon Q Business service.

  • ThrottlingException –

    The request was denied due to throttling. Reduce the number of requests and try again.

  • ValidationException –

    The input doesn't meet the constraints set by the Amazon Q Business service. Provide the correct input and try again.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_qbusiness/_services/q_business.py
def create_data_source(
    self,
    application_id: "capo_qbusiness.types.application_id.ApplicationId",
    index_id: "capo_qbusiness.types.index_id.IndexId",
    display_name: "capo_qbusiness.types.data_source_name.DataSourceName",
    configuration: "capo_qbusiness.types.data_source_configuration.DataSourceConfiguration",
    *,
    config_overrides: Optional[QBusinessClientConfig] = None,
    vpc_configuration: Optional[
        "capo_qbusiness.types.data_source_vpc_configuration.DataSourceVpcConfiguration"
    ] = None,
    description: Optional["capo_qbusiness.types.description.Description"] = None,
    tags: Optional["capo_qbusiness.types.tags.Tags"] = None,
    sync_schedule: Optional[
        "capo_qbusiness.types.sync_schedule.SyncSchedule"
    ] = None,
    role_arn: Optional["capo_qbusiness.types.role_arn.RoleArn"] = None,
    client_token: Optional["capo_qbusiness.types.client_token.ClientToken"] = None,
    document_enrichment_configuration: Optional[
        "capo_qbusiness.types.document_enrichment_configuration.DocumentEnrichmentConfiguration"
    ] = None,
    media_extraction_configuration: Optional[
        "capo_qbusiness.types.media_extraction_configuration.MediaExtractionConfiguration"
    ] = None,
) -> "capo_qbusiness.types.create_data_source_response.CreateDataSourceResponse":
    """<p>Creates a data source connector for an Amazon Q Business application.</p> <p> <code>CreateDataSource</code> is a synchronous operation. The operation returns 200 if the data source was successfully created. Otherwise, an exception is raised.</p>

    Args:
        application_id: <p> The identifier of the Amazon Q Business application the data source will be attached to.</p>
        index_id: <p>The identifier of the index that you want to use with the data source connector.</p>
        display_name: <p>A name for the data source connector.</p>
        configuration: <p>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.</p> <p>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:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/amazonq/latest/qbusiness-ug/s3-api.html">Amazon S3 JSON schema</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/amazonq/latest/qbusiness-ug/web-crawler-api.html">Web Crawler JSON schema</a> </p> </li> </ul> <p>You can find configuration templates for your specific data source using the following steps:</p> <ol> <li> <p>Navigate to the <a href="https://docs.aws.amazon.com/amazonq/latest/business-use-dg/connectors-list.html">Supported connectors</a> page in the Amazon Q Business User Guide, and select the data source of your choice.</p> </li> <li> <p>Then, from your specific data source connector page, select <b>Using the API</b>. You will find the JSON schema for your data source, including parameter descriptions, in this section.</p> </li> </ol>
        vpc_configuration: <p>Configuration information for an Amazon VPC (Virtual Private Cloud) to connect to your data source. For more information, see <a href="https://docs.aws.amazon.com/amazonq/latest/business-use-dg/connector-vpc.html">Using Amazon VPC with Amazon Q Business connectors</a>.</p>
        description: <p>A description for the data source connector.</p>
        tags: <p>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: _ . : / = + - @.</p>
        sync_schedule: <p>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.</p> <p>Specify a <code>cron-</code> format schedule string or an empty string to indicate that the index is updated on demand. You can't specify the <code>Schedule</code> parameter when the <code>Type</code> parameter is set to <code>CUSTOM</code>. If you do, you receive a <code>ValidationException</code> exception. </p>
        role_arn: <p>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.</p>
        client_token: <p>A token you provide to identify a request to create a data source connector. Multiple calls to the <code>CreateDataSource</code> API with the same client token will create only one data source connector. </p>
        media_extraction_configuration: <p>The configuration for extracting information from media in documents during ingestion.</p>

    Raises:
        capo_qbusiness.errors.access_denied_exception.AccessDeniedException: <p> You don't have access to perform this action. Make sure you have the required permission policies and user accounts and try again.</p>
        capo_qbusiness.errors.conflict_exception.ConflictException: <p>You are trying to perform an action that conflicts with the current status of your resource. Fix any inconsistencies with your resources and try again.</p>
        capo_qbusiness.errors.internal_server_exception.InternalServerException: <p>An issue occurred with the internal server used for your Amazon Q Business service. Wait some minutes and try again, or contact <a href="http://aws.amazon.com/contact-us/">Support</a> for help.</p>
        capo_qbusiness.errors.resource_not_found_exception.ResourceNotFoundException: <p>The application or plugin resource you want to use doesn’t exist. Make sure you have provided the correct resource and try again.</p>
        capo_qbusiness.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You have exceeded the set limits for your Amazon Q Business service. </p>
        capo_qbusiness.errors.throttling_exception.ThrottlingException: <p>The request was denied due to throttling. Reduce the number of requests and try again.</p>
        capo_qbusiness.errors.validation_exception.ValidationException: <p>The input doesn't meet the constraints set by the Amazon Q Business service. Provide the correct input and try again.</p>
        capo_qbusiness.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_qbusiness.types.create_data_source_request.CreateDataSourceRequest]",
    ) -> OperationResponse[
        "capo_qbusiness.types.create_data_source_response.CreateDataSourceResponse"
    ]:
        import capo_qbusiness._operations.expert_q.create_data_source

        output, http_response = (
            capo_qbusiness._operations.expert_q.create_data_source.create_data_source(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateDataSource")
    )
    input_: capo_qbusiness.types.create_data_source_request.CreateDataSourceRequest = {
        "application_id": application_id,
        "index_id": index_id,
        "display_name": display_name,
        "configuration": configuration,
    }
    if vpc_configuration is not None:
        input_["vpc_configuration"] = vpc_configuration
    if description is not None:
        input_["description"] = description
    if tags is not None:
        input_["tags"] = tags
    if sync_schedule is not None:
        input_["sync_schedule"] = sync_schedule
    if role_arn is not None:
        input_["role_arn"] = role_arn
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if document_enrichment_configuration is not None:
        input_["document_enrichment_configuration"] = (
            document_enrichment_configuration
        )
    if media_extraction_configuration is not None:
        input_["media_extraction_configuration"] = media_extraction_configuration

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output