Skip to content

create_data_source async

create_data_source(
    knowledge_base_id: Id,
    name: Name,
    data_source_configuration: DataSourceConfiguration,
    *,
    config_overrides: Optional[AsyncBedrockAgentClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    description: Optional[Description] = None,
    data_deletion_policy: Optional[DataDeletionPolicy] = None,
    server_side_encryption_configuration: Optional[
        ServerSideEncryptionConfiguration
    ] = None,
    vector_ingestion_configuration: Optional[VectorIngestionConfiguration] = None,
) -> CreateDataSourceResponse

Connects a knowledge base to a data source. You specify the configuration for the specific data source service in the dataSourceConfiguration field.

You can't change the chunkingConfiguration after you create the data source connector.

Parameters:

  • knowledge_base_id (Id) –

    The unique identifier of the knowledge base to which to add the data source.

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

    A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see Ensuring idempotency.

  • name (Name) –

    The name of the data source.

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

    A description of the data source.

  • data_source_configuration (DataSourceConfiguration) –

    The connection configuration for the data source.

  • data_deletion_policy (Optional[DataDeletionPolicy], default: None ) –

    The data deletion policy for the data source.

    You can set the data deletion policy to:

    • DELETE: Deletes all data from your data source that’s converted into vector embeddings upon deletion of a knowledge base or data source resource. Note that the vector store itself is not deleted, only the data. This flag is ignored if an Amazon Web Services account is deleted.

    • RETAIN: Retains all data from your data source that’s converted into vector embeddings upon deletion of a knowledge base or data source resource. Note that the vector store itself is not deleted if you delete a knowledge base or data source resource.

    For managed knowledge bases, the only supported option is DELETE, which is also the default.

  • server_side_encryption_configuration (Optional[ServerSideEncryptionConfiguration], default: None ) –

    Contains details about the server-side encryption for the data source.

  • vector_ingestion_configuration (Optional[VectorIngestionConfiguration], default: None ) –

    Contains details about how to ingest the documents in the data source.

Raises:

Source code in docs_src/capo_bedrock_agent/_services/async_bedrock_agent.py
async def create_data_source(
    self,
    knowledge_base_id: "capo_bedrock_agent.types.id.Id",
    name: "capo_bedrock_agent.types.name.Name",
    data_source_configuration: "capo_bedrock_agent.types.data_source_configuration.DataSourceConfiguration",
    *,
    config_overrides: Optional[AsyncBedrockAgentClientConfig] = None,
    client_token: Optional[
        "capo_bedrock_agent.types.client_token.ClientToken"
    ] = None,
    description: Optional[
        "capo_bedrock_agent.types.description.Description"
    ] = None,
    data_deletion_policy: Optional[
        "capo_bedrock_agent.types.data_deletion_policy.DataDeletionPolicy"
    ] = None,
    server_side_encryption_configuration: Optional[
        "capo_bedrock_agent.types.server_side_encryption_configuration.ServerSideEncryptionConfiguration"
    ] = None,
    vector_ingestion_configuration: Optional[
        "capo_bedrock_agent.types.vector_ingestion_configuration.VectorIngestionConfiguration"
    ] = None,
) -> (
    "capo_bedrock_agent.types.create_data_source_response.CreateDataSourceResponse"
):
    """<p>Connects a knowledge base to a data source. You specify the configuration for the specific data source service in the <code>dataSourceConfiguration</code> field.</p> <important> <p>You can't change the <code>chunkingConfiguration</code> after you create the data source connector.</p> </important>

    Args:
        knowledge_base_id: <p>The unique identifier of the knowledge base to which to add the data source.</p>
        client_token: <p>A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a>.</p>
        name: <p>The name of the data source.</p>
        description: <p>A description of the data source.</p>
        data_source_configuration: <p>The connection configuration for the data source.</p>
        data_deletion_policy: <p>The data deletion policy for the data source.</p> <p>You can set the data deletion policy to:</p> <ul> <li> <p>DELETE: Deletes all data from your data source that’s converted into vector embeddings upon deletion of a knowledge base or data source resource. Note that the <b>vector store itself is not deleted</b>, only the data. This flag is ignored if an Amazon Web Services account is deleted.</p> </li> <li> <p>RETAIN: Retains all data from your data source that’s converted into vector embeddings upon deletion of a knowledge base or data source resource. Note that the <b>vector store itself is not deleted</b> if you delete a knowledge base or data source resource.</p> </li> </ul> <note> <p>For managed knowledge bases, the only supported option is <code>DELETE</code>, which is also the default.</p> </note>
        server_side_encryption_configuration: <p>Contains details about the server-side encryption for the data source.</p>
        vector_ingestion_configuration: <p>Contains details about how to ingest the documents in the data source.</p>

    Raises:
        capo_bedrock_agent.errors.access_denied_exception.AccessDeniedException: <p>The request is denied because of missing access permissions.</p>
        capo_bedrock_agent.errors.conflict_exception.ConflictException: <p>There was a conflict performing an operation.</p>
        capo_bedrock_agent.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. Retry your request.</p>
        capo_bedrock_agent.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.</p>
        capo_bedrock_agent.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The number of requests exceeds the service quota. Resubmit your request later.</p>
        capo_bedrock_agent.errors.throttling_exception.ThrottlingException: <p>The number of requests exceeds the limit. Resubmit your request later.</p>
        capo_bedrock_agent.errors.validation_exception.ValidationException: <p>Input validation failed. Check your request parameters and retry the request.</p>
        capo_bedrock_agent.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_bedrock_agent.types.create_data_source_request.CreateDataSourceRequest]",
    ) -> AsyncOperationResponse[
        "capo_bedrock_agent.types.create_data_source_response.CreateDataSourceResponse"
    ]:
        import capo_bedrock_agent._operations.amazon_bedrock_agent_build_time_lambda.create_data_source

        (
            output,
            http_response,
        ) = await capo_bedrock_agent._operations.amazon_bedrock_agent_build_time_lambda.create_data_source.async_create_data_source(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_bedrock_agent.types.create_data_source_request.CreateDataSourceRequest",
    ) -> dict[str, Any]:
        import capo_bedrock_agent.types.create_data_source_request

        return capo_bedrock_agent.types.create_data_source_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_bedrock_agent.types.create_data_source_response.CreateDataSourceResponse",
    ) -> dict[str, Any]:
        import capo_bedrock_agent.types.create_data_source_response

        return (
            capo_bedrock_agent.types.create_data_source_response.redact_sensitive(
                output
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateDataSource",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_bedrock_agent.types.create_data_source_request.CreateDataSourceRequest = {
        "knowledge_base_id": knowledge_base_id,
        "name": name,
        "data_source_configuration": data_source_configuration,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if description is not None:
        input_["description"] = description
    if data_deletion_policy is not None:
        input_["data_deletion_policy"] = data_deletion_policy
    if server_side_encryption_configuration is not None:
        input_["server_side_encryption_configuration"] = (
            server_side_encryption_configuration
        )
    if vector_ingestion_configuration is not None:
        input_["vector_ingestion_configuration"] = vector_ingestion_configuration

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output