Skip to content

attach_data_source

attach_data_source(
    id: Id,
    data_source_arn: ARN,
    *,
    config_overrides: Optional[OpenSearchClientConfig] = None,
    workspace_id: Optional[String] = None,
    workspace_configuration: Optional[WorkspaceConfigurationInput] = None,
    client_token: Optional[ClientToken] = None,
) -> AttachDataSourceResponse

Attaches a data source to an OpenSearch application. The data source must be an Amazon OpenSearch Service domain. If both the application and the data source are active, the attachment completes immediately with a status of ATTACHED. Otherwise, the operation returns PENDING and completes the attachment automatically once both become active. If the attachment cannot be completed, its status becomes FAILED. This operation is idempotent: If the data source is already attached or pending, the operation returns the existing attachment.

Parameters:

  • id (Id) –

    The unique identifier or name of the OpenSearch application to attach the data source to. This is the same identifier used with UpdateApplication, GetApplication, and DeleteApplication.

  • workspace_id (Optional[String], default: None ) –

    The identifier of an existing workspace to update with the new data source. Mutually exclusive with workspaceConfiguration.

  • workspace_configuration (Optional[WorkspaceConfigurationInput], default: None ) –

    Configuration for creating a new workspace during the attachment. If specified, a workspace is created and linked to the data source after the attachment completes. Mutually exclusive with workspaceId.

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

    A unique, case-sensitive identifier to ensure idempotency of the request. If you retry a request with the same client token and the same parameters, the retry succeeds without performing any further actions.

Raises:

Source code in docs_src/capo_opensearch/_services/open_search.py
def attach_data_source(
    self,
    id: "capo_opensearch.types.id.Id",
    data_source_arn: "capo_opensearch.types.arn.ARN",
    *,
    config_overrides: Optional[OpenSearchClientConfig] = None,
    workspace_id: Optional["capo_opensearch.types.string.String"] = None,
    workspace_configuration: Optional[
        "capo_opensearch.types.workspace_configuration_input.WorkspaceConfigurationInput"
    ] = None,
    client_token: Optional["capo_opensearch.types.client_token.ClientToken"] = None,
) -> "capo_opensearch.types.attach_data_source_response.AttachDataSourceResponse":
    """<p>Attaches a data source to an OpenSearch application. The data source must be an Amazon OpenSearch Service domain. If both the application and the data source are active, the attachment completes immediately with a status of <code>ATTACHED</code>. Otherwise, the operation returns <code>PENDING</code> and completes the attachment automatically once both become active. If the attachment cannot be completed, its status becomes <code>FAILED</code>. This operation is idempotent: If the data source is already attached or pending, the operation returns the existing attachment.</p>

    Args:
        id: <p>The unique identifier or name of the OpenSearch application to attach the data source to. This is the same identifier used with <code>UpdateApplication</code>, <code>GetApplication</code>, and <code>DeleteApplication</code>.</p>
        workspace_id: <p>The identifier of an existing workspace to update with the new data source. Mutually exclusive with <code>workspaceConfiguration</code>.</p>
        workspace_configuration: <p>Configuration for creating a new workspace during the attachment. If specified, a workspace is created and linked to the data source after the attachment completes. Mutually exclusive with <code>workspaceId</code>.</p>
        client_token: <p>A unique, case-sensitive identifier to ensure idempotency of the request. If you retry a request with the same client token and the same parameters, the retry succeeds without performing any further actions.</p>

    Raises:
        capo_opensearch.errors.access_denied_exception.AccessDeniedException: <p>An error occurred because you don't have permissions to access the resource.</p>
        capo_opensearch.errors.conflict_exception.ConflictException: <p>An error occurred because the client attempts to remove a resource that is currently in use.</p>
        capo_opensearch.errors.disabled_operation_exception.DisabledOperationException: <p>An error occured because the client wanted to access an unsupported operation.</p>
        capo_opensearch.errors.internal_exception.InternalException: <p>Request processing failed because of an unknown error, exception, or internal failure.</p>
        capo_opensearch.errors.resource_not_found_exception.ResourceNotFoundException: <p>An exception for accessing or deleting a resource that doesn't exist.</p>
        capo_opensearch.errors.validation_exception.ValidationException: <p>An exception for accessing or deleting a resource that doesn't exist.</p>
        capo_opensearch.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_opensearch.types.attach_data_source_request.AttachDataSourceRequest]",
    ) -> OperationResponse[
        "capo_opensearch.types.attach_data_source_response.AttachDataSourceResponse"
    ]:
        import capo_opensearch._operations.amazon_open_search_service.attach_data_source

        output, http_response = (
            capo_opensearch._operations.amazon_open_search_service.attach_data_source.attach_data_source(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AttachDataSource")
    )
    input_: capo_opensearch.types.attach_data_source_request.AttachDataSourceRequest = {
        "id": id,
        "data_source_arn": data_source_arn,
    }
    if workspace_id is not None:
        input_["workspace_id"] = workspace_id
    if workspace_configuration is not None:
        input_["workspace_configuration"] = workspace_configuration
    if client_token is not None:
        input_["client_token"] = client_token

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