attachDataSource method

Future<AttachDataSourceResponse> attachDataSource({
  1. required String dataSourceArn,
  2. required String id,
  3. String? clientToken,
  4. WorkspaceConfigurationInput? workspaceConfiguration,
  5. String? workspaceId,
})

Attaches a data source to an OpenSearch application. The data source can be an Amazon OpenSearch Service domain or an Amazon OpenSearch Serverless collection. If both the application and data source are in the ACTIVE state, the attachment completes immediately and returns a status of ATTACHED. If either resource is not yet active, the operation stores the request and returns a status of PENDING. A background process then completes the attachment when both resources become active. Pending attachments that are not completed within 24 hours are marked as FAILED. This operation is idempotent. If a data source is already attached or pending for the same application, the existing attachment is returned.

May throw AccessDeniedException. May throw ConflictException. May throw DisabledOperationException. May throw InternalException. May throw ResourceNotFoundException. May throw ValidationException.

Parameter 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.

Parameter clientToken : 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.

Parameter workspaceConfiguration : 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.

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

Implementation

Future<AttachDataSourceResponse> attachDataSource({
  required String dataSourceArn,
  required String id,
  String? clientToken,
  WorkspaceConfigurationInput? workspaceConfiguration,
  String? workspaceId,
}) async {
  final $payload = <String, dynamic>{
    'dataSourceArn': dataSourceArn,
    if (clientToken != null) 'clientToken': clientToken,
    if (workspaceConfiguration != null)
      'workspaceConfiguration': workspaceConfiguration,
    if (workspaceId != null) 'workspaceId': workspaceId,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/2021-01-01/opensearch/application/${Uri.encodeComponent(id)}/attachDataSource',
    exceptionFnMap: _exceptionFns,
  );
  return AttachDataSourceResponse.fromJson(response);
}