diff --git a/sdk/search/azure-search-documents/CHANGELOG.md b/sdk/search/azure-search-documents/CHANGELOG.md index b1fe02b7b407..1bde75f7e015 100644 --- a/sdk/search/azure-search-documents/CHANGELOG.md +++ b/sdk/search/azure-search-documents/CHANGELOG.md @@ -8,6 +8,10 @@ - Removed `SearchServiceClientBuilder`. - Renamed `SearchIndexClient` to `SearchClient` and `SearchIndexAsyncClient` to `SearchAsyncClient`. - Put all models used `SearchIndexClient` and `SearchIndexerClient` (same for async clients) under `com.azure.search.documents.indexes`. +- Removed `SearchIndexerDataSource` to `SearchIndexerDataSourceConnection`, +- Renamed methods on `SearchIndexerClient` and `SearchIndexerAsyncClient` idiomatically matching "DataSource" to "DataSourceConnection". +- Removed `DataSourceCredential` and `AzureActiveDirectoryApplicationCredentials`, +and uplifted the properties to `SearchIndexerDataSourceConnection` and `SearchResourceEncryptionKey` respectively. - Removed `select` parameter from list service resource APIs. - Added list names APIs for each search service resource. (e.g. `listSearchIndexNames`, `listSearchIndexerNames`, `listDataSourceNames`, `listSkillsetNames`, `listSynonymMapNames`) diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/AzureActiveDirectoryApplicationCredentialsConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/AzureActiveDirectoryApplicationCredentialsConverter.java deleted file mode 100644 index cfd8f2d024be..000000000000 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/AzureActiveDirectoryApplicationCredentialsConverter.java +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.search.documents.implementation.converters; - -import com.azure.search.documents.indexes.models.AzureActiveDirectoryApplicationCredentials; - -/** - * A converter between - * {@link com.azure.search.documents.indexes.implementation.models.AzureActiveDirectoryApplicationCredentials} and - * {@link AzureActiveDirectoryApplicationCredentials}. - */ -public final class AzureActiveDirectoryApplicationCredentialsConverter { - /** - * Maps from {@link com.azure.search.documents.indexes.implementation.models.AzureActiveDirectoryApplicationCredentials} to - * {@link AzureActiveDirectoryApplicationCredentials}. - */ - public static AzureActiveDirectoryApplicationCredentials map(com.azure.search.documents.indexes.implementation.models.AzureActiveDirectoryApplicationCredentials obj) { - if (obj == null) { - return null; - } - AzureActiveDirectoryApplicationCredentials azureActiveDirectoryApplicationCredentials = - new AzureActiveDirectoryApplicationCredentials(); - - String applicationId = obj.getApplicationId(); - azureActiveDirectoryApplicationCredentials.setApplicationId(applicationId); - - String applicationSecret = obj.getApplicationSecret(); - azureActiveDirectoryApplicationCredentials.setApplicationSecret(applicationSecret); - return azureActiveDirectoryApplicationCredentials; - } - - /** - * Maps from {@link AzureActiveDirectoryApplicationCredentials} to - * {@link com.azure.search.documents.indexes.implementation.models.AzureActiveDirectoryApplicationCredentials}. - */ - public static com.azure.search.documents.indexes.implementation.models.AzureActiveDirectoryApplicationCredentials map(AzureActiveDirectoryApplicationCredentials obj) { - if (obj == null) { - return null; - } - com.azure.search.documents.indexes.implementation.models.AzureActiveDirectoryApplicationCredentials - azureActiveDirectoryApplicationCredentials = - new com.azure.search.documents.indexes.implementation.models.AzureActiveDirectoryApplicationCredentials(); - - String applicationId = obj.getApplicationId(); - azureActiveDirectoryApplicationCredentials.setApplicationId(applicationId); - - String applicationSecret = obj.getApplicationSecret(); - azureActiveDirectoryApplicationCredentials.setApplicationSecret(applicationSecret); - return azureActiveDirectoryApplicationCredentials; - } - - private AzureActiveDirectoryApplicationCredentialsConverter() { - } -} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/DataSourceCredentialsConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/DataSourceCredentialsConverter.java deleted file mode 100644 index 9cffff68941e..000000000000 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/DataSourceCredentialsConverter.java +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.search.documents.implementation.converters; - -import com.azure.search.documents.indexes.models.DataSourceCredentials; - -/** - * A converter between {@link com.azure.search.documents.indexes.implementation.models.DataSourceCredentials} and - * {@link DataSourceCredentials}. - */ -public final class DataSourceCredentialsConverter { - /** - * Maps from {@link com.azure.search.documents.indexes.implementation.models.DataSourceCredentials} to - * {@link DataSourceCredentials}. - */ - public static DataSourceCredentials map(com.azure.search.documents.indexes.implementation.models.DataSourceCredentials obj) { - if (obj == null) { - return null; - } - DataSourceCredentials dataSourceCredentials = new DataSourceCredentials(); - - String connectionString = obj.getConnectionString(); - dataSourceCredentials.setConnectionString(connectionString); - return dataSourceCredentials; - } - - /** - * Maps from {@link DataSourceCredentials} to - * {@link com.azure.search.documents.indexes.implementation.models.DataSourceCredentials}. - */ - public static com.azure.search.documents.indexes.implementation.models.DataSourceCredentials map(DataSourceCredentials obj) { - if (obj == null) { - return null; - } - com.azure.search.documents.indexes.implementation.models.DataSourceCredentials dataSourceCredentials = - new com.azure.search.documents.indexes.implementation.models.DataSourceCredentials(); - - String connectionString = obj.getConnectionString(); - dataSourceCredentials.setConnectionString(connectionString); - return dataSourceCredentials; - } - - private DataSourceCredentialsConverter() { - } -} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchIndexerDataSourceConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchIndexerDataSourceConverter.java index 357c4bd185f2..5e32277bf641 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchIndexerDataSourceConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchIndexerDataSourceConverter.java @@ -3,76 +3,75 @@ package com.azure.search.documents.implementation.converters; +import com.azure.search.documents.indexes.implementation.models.DataSourceCredentials; +import com.azure.search.documents.indexes.implementation.models.SearchIndexerDataSource; import com.azure.search.documents.indexes.models.DataChangeDetectionPolicy; import com.azure.search.documents.indexes.models.DataDeletionDetectionPolicy; -import com.azure.search.documents.indexes.models.DataSourceCredentials; import com.azure.search.documents.indexes.models.SearchIndexerDataContainer; -import com.azure.search.documents.indexes.models.SearchIndexerDataSource; +import com.azure.search.documents.indexes.models.SearchIndexerDataSourceConnection; import com.azure.search.documents.indexes.models.SearchIndexerDataSourceType; /** - * A converter between {@link com.azure.search.documents.indexes.implementation.models.SearchIndexerDataSource} and - * {@link SearchIndexerDataSource}. + * A converter between {@link SearchIndexerDataSource} and + * {@link SearchIndexerDataSourceConnection}. */ public final class SearchIndexerDataSourceConverter { /** - * Maps from {@link com.azure.search.documents.indexes.implementation.models.SearchIndexerDataSource} to - * {@link SearchIndexerDataSource}. + * Maps from {@link SearchIndexerDataSource} to + * {@link SearchIndexerDataSourceConnection}. */ - public static SearchIndexerDataSource map(com.azure.search.documents.indexes.implementation.models.SearchIndexerDataSource obj) { + public static SearchIndexerDataSourceConnection map(SearchIndexerDataSource obj) { if (obj == null) { return null; } - SearchIndexerDataSource searchIndexerDataSource = new SearchIndexerDataSource(); + SearchIndexerDataSourceConnection searchIndexerDataSourceConnection = new SearchIndexerDataSourceConnection(); if (obj.getContainer() != null) { SearchIndexerDataContainer container = SearchIndexerDataContainerConverter.map(obj.getContainer()); - searchIndexerDataSource.setContainer(container); + searchIndexerDataSourceConnection.setContainer(container); } if (obj.getDataChangeDetectionPolicy() != null) { DataChangeDetectionPolicy dataChangeDetectionPolicy = DataChangeDetectionPolicyConverter.map(obj.getDataChangeDetectionPolicy()); - searchIndexerDataSource.setDataChangeDetectionPolicy(dataChangeDetectionPolicy); + searchIndexerDataSourceConnection.setDataChangeDetectionPolicy(dataChangeDetectionPolicy); } - if (obj.getCredentials() != null) { - DataSourceCredentials credentials = DataSourceCredentialsConverter.map(obj.getCredentials()); - searchIndexerDataSource.setCredentials(credentials); + searchIndexerDataSourceConnection.setConnectionString(obj.getCredentials().getConnectionString()); } String name = obj.getName(); - searchIndexerDataSource.setName(name); + searchIndexerDataSourceConnection.setName(name); String description = obj.getDescription(); - searchIndexerDataSource.setDescription(description); + searchIndexerDataSourceConnection.setDescription(description); if (obj.getDataDeletionDetectionPolicy() != null) { DataDeletionDetectionPolicy dataDeletionDetectionPolicy = DataDeletionDetectionPolicyConverter.map(obj.getDataDeletionDetectionPolicy()); - searchIndexerDataSource.setDataDeletionDetectionPolicy(dataDeletionDetectionPolicy); + searchIndexerDataSourceConnection.setDataDeletionDetectionPolicy(dataDeletionDetectionPolicy); } String eTag = obj.getETag(); - searchIndexerDataSource.setETag(eTag); + searchIndexerDataSourceConnection.setETag(eTag); if (obj.getType() != null) { SearchIndexerDataSourceType type = SearchIndexerDataSourceTypeConverter.map(obj.getType()); - searchIndexerDataSource.setType(type); + searchIndexerDataSourceConnection.setType(type); } - return searchIndexerDataSource; + return searchIndexerDataSourceConnection; } /** - * Maps from {@link SearchIndexerDataSource} to - * {@link com.azure.search.documents.indexes.implementation.models.SearchIndexerDataSource}. + * Maps from {@link SearchIndexerDataSourceConnection} to + * {@link SearchIndexerDataSource}. */ - public static com.azure.search.documents.indexes.implementation.models.SearchIndexerDataSource map(SearchIndexerDataSource obj) { + public static SearchIndexerDataSource map(SearchIndexerDataSourceConnection obj) { if (obj == null) { return null; } - com.azure.search.documents.indexes.implementation.models.SearchIndexerDataSource searchIndexerDataSource = - new com.azure.search.documents.indexes.implementation.models.SearchIndexerDataSource(); + SearchIndexerDataSource searchIndexerDataSource = + new SearchIndexerDataSource(); if (obj.getContainer() != null) { com.azure.search.documents.indexes.implementation.models.SearchIndexerDataContainer container = @@ -81,16 +80,14 @@ public static com.azure.search.documents.indexes.implementation.models.SearchInd } if (obj.getDataChangeDetectionPolicy() != null) { - com.azure.search.documents.indexes.implementation.models.DataChangeDetectionPolicy dataChangeDetectionPolicy = - DataChangeDetectionPolicyConverter.map(obj.getDataChangeDetectionPolicy()); + com.azure.search.documents.indexes.implementation.models.DataChangeDetectionPolicy + dataChangeDetectionPolicy = DataChangeDetectionPolicyConverter.map(obj.getDataChangeDetectionPolicy()); searchIndexerDataSource.setDataChangeDetectionPolicy(dataChangeDetectionPolicy); } - if (obj.getCredentials() != null) { - com.azure.search.documents.indexes.implementation.models.DataSourceCredentials credentials = - DataSourceCredentialsConverter.map(obj.getCredentials()); - searchIndexerDataSource.setCredentials(credentials); - } + DataSourceCredentials credentials = new DataSourceCredentials(); + credentials.setConnectionString(obj.getConnectionString()); + searchIndexerDataSource.setCredentials(credentials); String name = obj.getName(); searchIndexerDataSource.setName(name); diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchResourceEncryptionKeyConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchResourceEncryptionKeyConverter.java index 222fa868294f..bf14aab4c09e 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchResourceEncryptionKeyConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchResourceEncryptionKeyConverter.java @@ -3,7 +3,7 @@ package com.azure.search.documents.implementation.converters; -import com.azure.search.documents.indexes.models.AzureActiveDirectoryApplicationCredentials; +import com.azure.search.documents.indexes.implementation.models.AzureActiveDirectoryApplicationCredentials; import com.azure.search.documents.indexes.models.SearchResourceEncryptionKey; /** @@ -24,11 +24,8 @@ public static SearchResourceEncryptionKey map(com.azure.search.documents.indexes String keyVersion = obj.getKeyVersion(); searchResourceEncryptionKey.setKeyVersion(keyVersion); - if (obj.getAccessCredentials() != null) { - AzureActiveDirectoryApplicationCredentials accessCredentials = - AzureActiveDirectoryApplicationCredentialsConverter.map(obj.getAccessCredentials()); - searchResourceEncryptionKey.setAccessCredentials(accessCredentials); - } + searchResourceEncryptionKey.setApplicationId(obj.getAccessCredentials().getApplicationId()); + searchResourceEncryptionKey.setApplicationSecret(obj.getAccessCredentials().getApplicationSecret()); String keyName = obj.getKeyName(); searchResourceEncryptionKey.setKeyName(keyName); @@ -52,10 +49,12 @@ public static com.azure.search.documents.indexes.implementation.models.SearchRes String keyVersion = obj.getKeyVersion(); searchResourceEncryptionKey.setKeyVersion(keyVersion); - if (obj.getAccessCredentials() != null) { - com.azure.search.documents.indexes.implementation.models.AzureActiveDirectoryApplicationCredentials accessCredentials = AzureActiveDirectoryApplicationCredentialsConverter.map(obj.getAccessCredentials()); - searchResourceEncryptionKey.setAccessCredentials(accessCredentials); - } + AzureActiveDirectoryApplicationCredentials accessCredentials = + new AzureActiveDirectoryApplicationCredentials(); + accessCredentials.setApplicationId(obj.getApplicationId()); + accessCredentials.setApplicationSecret(obj.getApplicationSecret()); + searchResourceEncryptionKey.setAccessCredentials(accessCredentials); + String keyName = obj.getKeyName(); searchResourceEncryptionKey.setKeyName(keyName); diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/util/MappingUtils.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/util/MappingUtils.java index 7ff150d75290..a602211615e5 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/util/MappingUtils.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/util/MappingUtils.java @@ -33,7 +33,7 @@ import com.azure.search.documents.indexes.models.GetIndexStatisticsResult; import com.azure.search.documents.indexes.models.SearchIndex; import com.azure.search.documents.indexes.models.SearchIndexer; -import com.azure.search.documents.indexes.models.SearchIndexerDataSource; +import com.azure.search.documents.indexes.models.SearchIndexerDataSourceConnection; import com.azure.search.documents.indexes.models.SearchIndexerSkillset; import com.azure.search.documents.indexes.models.SearchIndexerStatus; import com.azure.search.documents.indexes.models.ServiceStatistics; @@ -46,17 +46,17 @@ public class MappingUtils { - public static Response mappingExternalDataSource( + public static Response mappingExternalDataSource( Response dataSourceResponse) { return new SimpleResponse<>(dataSourceResponse, SearchIndexerDataSourceConverter.map(dataSourceResponse.getValue())); } - public static PagedResponse mappingPagingDataSource( + public static PagedResponse mappingPagingDataSource( Response dataSourceResponse) { - List dataSourceMaps = dataSourceResponse.getValue().getDataSources().stream() + List dataSourceMaps = dataSourceResponse.getValue().getDataSources().stream() .map(SearchIndexerDataSourceConverter::map).collect(toList()); - return new PagedResponseBase( + return new PagedResponseBase( dataSourceResponse.getRequest(), dataSourceResponse.getStatusCode(), dataSourceResponse.getHeaders(), dataSourceMaps, null, null); } @@ -64,7 +64,8 @@ public static PagedResponse mappingPagingDataSource( public static PagedResponse mappingPagingDataSourceNames( Response dataSourceResponse) { List dataSourceNames = dataSourceResponse.getValue().getDataSources().stream() - .map(SearchIndexerDataSourceConverter::map).map(SearchIndexerDataSource::getName).collect(toList()); + .map(SearchIndexerDataSourceConverter::map) + .map(SearchIndexerDataSourceConnection::getName).collect(toList()); return new PagedResponseBase( dataSourceResponse.getRequest(), dataSourceResponse.getStatusCode(), dataSourceResponse.getHeaders(), dataSourceNames, null, null); @@ -79,7 +80,7 @@ public static PagedResponse mappingPagingSearchIndex( searchIndices, null, null); } - public static PagedResponse mappingPagingSearchIndexNames(Response + public static PagedResponse mappingPagingSearchIndexNames(Response searchIndexResponse) { List searchIndexNames = searchIndexResponse.getValue().getIndexes().stream() .map(SearchIndexConverter::map).map(SearchIndex::getName).collect(toList()); diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerAsyncClient.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerAsyncClient.java index 8adba2f2d746..aea69243eb60 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerAsyncClient.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerAsyncClient.java @@ -22,7 +22,7 @@ import com.azure.search.documents.indexes.implementation.models.ListIndexersResult; import com.azure.search.documents.indexes.implementation.models.ListSkillsetsResult; import com.azure.search.documents.indexes.models.SearchIndexer; -import com.azure.search.documents.indexes.models.SearchIndexerDataSource; +import com.azure.search.documents.indexes.models.SearchIndexerDataSourceConnection; import com.azure.search.documents.indexes.models.SearchIndexerSkillset; import com.azure.search.documents.indexes.models.SearchIndexerStatus; import com.azure.search.documents.models.RequestOptions; @@ -106,30 +106,32 @@ public String getEndpoint() { /** * Creates a new Azure Cognitive Search data source or updates a data source if it already exists. * - * @param dataSource The definition of the {@link SearchIndexerDataSource} to create or update. + * @param dataSource The definition of the {@link SearchIndexerDataSourceConnection} to create or update. * @return the data source that was created or updated. */ - public Mono createOrUpdateDataSource(SearchIndexerDataSource dataSource) { - return createOrUpdateDataSourceWithResponse(dataSource, false, null).map(Response::getValue); + public Mono createOrUpdateDataSourceConnection( + SearchIndexerDataSourceConnection dataSource) { + return createOrUpdateDataSourceConnectionWithResponse(dataSource, false, null).map(Response::getValue); } /** * Creates a new Azure Cognitive Search data source or updates a data source if it already exists. * - * @param dataSource The definition of the {@link SearchIndexerDataSource} to create or update. + * @param dataSource The definition of the {@link SearchIndexerDataSourceConnection} to create or update. * @param onlyIfUnchanged {@code true} to update if the {@code dataSource} is the same as the current service value. * {@code false} to always update existing value. * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to * help with debugging * @return a data source response. */ - public Mono> createOrUpdateDataSourceWithResponse( - SearchIndexerDataSource dataSource, boolean onlyIfUnchanged, RequestOptions requestOptions) { + public Mono> createOrUpdateDataSourceConnectionWithResponse( + SearchIndexerDataSourceConnection dataSource, boolean onlyIfUnchanged, RequestOptions requestOptions) { return withContext(context -> - createOrUpdateDataSourceWithResponse(dataSource, onlyIfUnchanged, requestOptions, context)); + createOrUpdateDataSourceConnectionWithResponse(dataSource, onlyIfUnchanged, requestOptions, context)); } - Mono> createOrUpdateDataSourceWithResponse(SearchIndexerDataSource dataSource, + Mono> createOrUpdateDataSourceConnectionWithResponse( + SearchIndexerDataSourceConnection dataSource, boolean onlyIfUnchanged, RequestOptions requestOptions, Context context) { Objects.requireNonNull(dataSource, "'DataSource' cannot be null."); String ifMatch = onlyIfUnchanged ? dataSource.getETag() : null; @@ -152,25 +154,26 @@ Mono> createOrUpdateDataSourceWithResponse(Sea * @param dataSource The definition of the dataSource to create. * @return a Mono which performs the network request upon subscription. */ - public Mono createDataSource(SearchIndexerDataSource dataSource) { - return createDataSourceWithResponse(dataSource, null).map(Response::getValue); + public Mono createDataSourceConnection( + SearchIndexerDataSourceConnection dataSource) { + return createDataSourceConnectionWithResponse(dataSource, null).map(Response::getValue); } /** * Creates a new Azure Cognitive Search data source * - * @param dataSource The definition of the {@link SearchIndexerDataSource} to create. + * @param dataSource The definition of the {@link SearchIndexerDataSourceConnection} to create. * @param requestOptions Additional parameters for the operation. Contains the tracking ID sent with the request to * help with debugging. * @return a Mono which performs the network request upon subscription. */ - public Mono> createDataSourceWithResponse(SearchIndexerDataSource dataSource, - RequestOptions requestOptions) { - return withContext(context -> this.createDataSourceWithResponse(dataSource, requestOptions, context)); + public Mono> createDataSourceConnectionWithResponse( + SearchIndexerDataSourceConnection dataSource, RequestOptions requestOptions) { + return withContext(context -> this.createDataSourceConnectionWithResponse(dataSource, requestOptions, context)); } - Mono> createDataSourceWithResponse(SearchIndexerDataSource dataSource, - RequestOptions requestOptions, Context context) { + Mono> createDataSourceConnectionWithResponse( + SearchIndexerDataSourceConnection dataSource, RequestOptions requestOptions, Context context) { try { return restClient.dataSources() .createWithRestResponseAsync(SearchIndexerDataSourceConverter.map(dataSource), @@ -185,27 +188,27 @@ Mono> createDataSourceWithResponse(SearchIndex /** * Retrieves a DataSource from an Azure Cognitive Search service. * - * @param dataSourceName the name of the {@link SearchIndexerDataSource} to retrieve. + * @param dataSourceName the name of the {@link SearchIndexerDataSourceConnection} to retrieve. * @return the DataSource. */ - public Mono getDataSource(String dataSourceName) { - return getDataSourceWithResponse(dataSourceName, null).map(Response::getValue); + public Mono getDataSourceConnection(String dataSourceName) { + return getDataSourceConnectionWithResponse(dataSourceName, null).map(Response::getValue); } /** * Retrieves a DataSource from an Azure Cognitive Search service. * - * @param dataSourceName the name of the {@link SearchIndexerDataSource} to retrieve. + * @param dataSourceName the name of the {@link SearchIndexerDataSourceConnection} to retrieve. * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to * help with debugging. * @return a response containing the DataSource. */ - public Mono> getDataSourceWithResponse(String dataSourceName, + public Mono> getDataSourceConnectionWithResponse(String dataSourceName, RequestOptions requestOptions) { - return withContext(context -> getDataSourceWithResponse(dataSourceName, requestOptions, context)); + return withContext(context -> getDataSourceConnectionWithResponse(dataSourceName, requestOptions, context)); } - Mono> getDataSourceWithResponse(String dataSourceName, + Mono> getDataSourceConnectionWithResponse(String dataSourceName, RequestOptions requestOptions, Context context) { try { return restClient.dataSources() @@ -222,8 +225,8 @@ Mono> getDataSourceWithResponse(String dataSou * * @return a list of DataSources */ - public PagedFlux listDataSources() { - return listDataSources(null, null); + public PagedFlux listDataSourceConnections() { + return listDataSourceConnections(null, null); } /** @@ -233,19 +236,20 @@ public PagedFlux listDataSources() { * help with debugging. * @return a list of DataSources */ - public PagedFlux listDataSources(RequestOptions requestOptions) { + public PagedFlux listDataSourceConnection(RequestOptions requestOptions) { try { return new PagedFlux<>(() -> - withContext(context -> this.listDataSourcesWithResponse(null, requestOptions, context)) + withContext(context -> this.listDataSourceConnectionsWithResponse(null, requestOptions, context)) .map(MappingUtils::mappingPagingDataSource)); } catch (RuntimeException ex) { return pagedFluxError(logger, ex); } } - PagedFlux listDataSources(RequestOptions requestOptions, Context context) { + PagedFlux listDataSourceConnections(RequestOptions requestOptions, + Context context) { try { - return new PagedFlux<>(() -> this.listDataSourcesWithResponse(null, requestOptions, context) + return new PagedFlux<>(() -> this.listDataSourceConnectionsWithResponse(null, requestOptions, context) .map(MappingUtils::mappingPagingDataSource)); } catch (RuntimeException ex) { return pagedFluxError(logger, ex); @@ -257,8 +261,8 @@ PagedFlux listDataSources(RequestOptions requestOptions * * @return a list of DataSource names */ - public PagedFlux listDataSourceNames() { - return listDataSources(null, null); + public PagedFlux listDataSourceConnectionNames() { + return listDataSourceConnectionNames(null, null); } /** @@ -268,26 +272,26 @@ public PagedFlux listDataSourceNames() { * help with debugging. * @return a list of DataSource names */ - public PagedFlux listDataSourceNames(RequestOptions requestOptions) { + public PagedFlux listDataSourceConnectionNames(RequestOptions requestOptions) { try { return new PagedFlux<>(() -> - withContext(context -> this.listDataSourcesWithResponse("name", requestOptions, context)) + withContext(context -> this.listDataSourceConnectionsWithResponse("name", requestOptions, context)) .map(MappingUtils::mappingPagingDataSourceNames)); } catch (RuntimeException ex) { return pagedFluxError(logger, ex); } } - PagedFlux listDataSourceNames(RequestOptions requestOptions, Context context) { + PagedFlux listDataSourceConnectionNames(RequestOptions requestOptions, Context context) { try { - return new PagedFlux<>(() -> this.listDataSourcesWithResponse("name", requestOptions, context) + return new PagedFlux<>(() -> this.listDataSourceConnectionsWithResponse("name", requestOptions, context) .map(MappingUtils::mappingPagingDataSourceNames)); } catch (RuntimeException ex) { return pagedFluxError(logger, ex); } } - private Mono> listDataSourcesWithResponse(String select, + private Mono> listDataSourceConnectionsWithResponse(String select, RequestOptions requestOptions, Context context) { return restClient.dataSources() .listWithRestResponseAsync(select, RequestOptionsIndexesConverter.map(requestOptions), context) @@ -297,34 +301,34 @@ private Mono> listDataSourcesWithResponse( /** * Delete a DataSource * - * @param dataSourceName the name of the {@link SearchIndexerDataSource} for deletion + * @param dataSourceName the name of the {@link SearchIndexerDataSourceConnection} for deletion * @return a void Mono */ - public Mono deleteDataSource(String dataSourceName) { + public Mono deleteDataSourceConnection(String dataSourceName) { return withContext(context -> - deleteDataSourceWithResponse(dataSourceName, null, null, context).flatMap(FluxUtil::toMono)); + deleteDataSourceConnectionWithResponse(dataSourceName, null, null, context).flatMap(FluxUtil::toMono)); } /** * Deletes an Azure Cognitive Search data source. * - * @param dataSource The {@link SearchIndexerDataSource} to delete. + * @param dataSource The {@link SearchIndexerDataSourceConnection} to delete. * @param onlyIfUnchanged {@code true} to delete if the {@code dataSource} is the same as the current service value. * {@code false} to always delete existing value. * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to * help with debugging * @return a mono response */ - public Mono> deleteDataSourceWithResponse(SearchIndexerDataSource dataSource, + public Mono> deleteDataSourceConnectionWithResponse(SearchIndexerDataSourceConnection dataSource, boolean onlyIfUnchanged, RequestOptions requestOptions) { Objects.requireNonNull(dataSource, "'DataSource' cannot be null"); String etag = onlyIfUnchanged ? dataSource.getETag() : null; return withContext(context -> - deleteDataSourceWithResponse(dataSource.getName(), etag, requestOptions, context)); + deleteDataSourceConnectionWithResponse(dataSource.getName(), etag, requestOptions, context)); } - Mono> deleteDataSourceWithResponse(String dataSourceName, String etag, RequestOptions requestOptions, - Context context) { + Mono> deleteDataSourceConnectionWithResponse(String dataSourceName, String etag, + RequestOptions requestOptions, Context context) { try { return restClient.dataSources() .deleteWithRestResponseAsync( diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerClient.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerClient.java index 2eadea7fca4b..038d9bb89785 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerClient.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerClient.java @@ -9,7 +9,7 @@ import com.azure.core.util.Context; import com.azure.search.documents.SearchServiceVersion; import com.azure.search.documents.indexes.models.SearchIndexer; -import com.azure.search.documents.indexes.models.SearchIndexerDataSource; +import com.azure.search.documents.indexes.models.SearchIndexerDataSourceConnection; import com.azure.search.documents.indexes.models.SearchIndexerSkillset; import com.azure.search.documents.indexes.models.SearchIndexerStatus; import com.azure.search.documents.models.RequestOptions; @@ -57,14 +57,15 @@ public String getEndpoint() { * @param dataSource The definition of the data source to create or update. * @return the data source that was created or updated. */ - public SearchIndexerDataSource createOrUpdateDataSource(SearchIndexerDataSource dataSource) { - return createOrUpdateDataSourceWithResponse(dataSource, false, null, Context.NONE).getValue(); + public SearchIndexerDataSourceConnection createOrUpdateDataSourceConnection( + SearchIndexerDataSourceConnection dataSource) { + return createOrUpdateDataSourceConnectionWithResponse(dataSource, false, null, Context.NONE).getValue(); } /** * Creates a new Azure Cognitive Search data source or updates a data source if it already exists. * - * @param dataSource the {@link SearchIndexerDataSource} to create or update + * @param dataSource the {@link SearchIndexerDataSourceConnection} to create or update * @param onlyIfUnchanged {@code true} to update if the {@code dataSource} is the same as the current service value. * {@code false} to always update existing value. * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to @@ -72,10 +73,11 @@ public SearchIndexerDataSource createOrUpdateDataSource(SearchIndexerDataSource * @param context additional context that is passed through the HTTP pipeline during the service call * @return a response containing data source that was created or updated. */ - public Response createOrUpdateDataSourceWithResponse(SearchIndexerDataSource dataSource, - boolean onlyIfUnchanged, RequestOptions requestOptions, Context context) { - return asyncClient.createOrUpdateDataSourceWithResponse(dataSource, onlyIfUnchanged, requestOptions, context) - .block(); + public Response createOrUpdateDataSourceConnectionWithResponse( + SearchIndexerDataSourceConnection dataSource, boolean onlyIfUnchanged, RequestOptions requestOptions, + Context context) { + return asyncClient.createOrUpdateDataSourceConnectionWithResponse(dataSource, onlyIfUnchanged, requestOptions, + context).block(); } /** @@ -84,8 +86,9 @@ public Response createOrUpdateDataSourceWithResponse(Se * @param dataSource The definition of the data source to create * @return the data source that was created. */ - public SearchIndexerDataSource createDataSource(SearchIndexerDataSource dataSource) { - return createDataSourceWithResponse(dataSource, null, Context.NONE).getValue(); + public SearchIndexerDataSourceConnection createDataSourceConnection( + SearchIndexerDataSourceConnection dataSource) { + return createDataSourceConnectionWithResponse(dataSource, null, Context.NONE).getValue(); } /** @@ -97,9 +100,9 @@ public SearchIndexerDataSource createDataSource(SearchIndexerDataSource dataSour * @param context additional context that is passed through the HTTP pipeline during the service call * @return a response containing data source that was created. */ - public Response createDataSourceWithResponse(SearchIndexerDataSource dataSource, - RequestOptions requestOptions, Context context) { - return asyncClient.createDataSourceWithResponse(dataSource, requestOptions, context).block(); + public Response createDataSourceConnectionWithResponse( + SearchIndexerDataSourceConnection dataSource, RequestOptions requestOptions, Context context) { + return asyncClient.createDataSourceConnectionWithResponse(dataSource, requestOptions, context).block(); } /** @@ -108,8 +111,8 @@ public Response createDataSourceWithResponse(SearchInde * @param dataSourceName the name of the data source to retrieve * @return the DataSource. */ - public SearchIndexerDataSource getDataSource(String dataSourceName) { - return getDataSourceWithResponse(dataSourceName, null, Context.NONE).getValue(); + public SearchIndexerDataSourceConnection getDataSourceConnection(String dataSourceName) { + return getDataSourceConnectionWithResponse(dataSourceName, null, Context.NONE).getValue(); } /** @@ -121,9 +124,9 @@ public SearchIndexerDataSource getDataSource(String dataSourceName) { * @param context additional context that is passed through the HTTP pipeline during the service call * @return a response containing the DataSource. */ - public Response getDataSourceWithResponse(String dataSourceName, + public Response getDataSourceConnectionWithResponse(String dataSourceName, RequestOptions requestOptions, Context context) { - return asyncClient.getDataSourceWithResponse(dataSourceName, requestOptions, context).block(); + return asyncClient.getDataSourceConnectionWithResponse(dataSourceName, requestOptions, context).block(); } /** @@ -131,8 +134,8 @@ public Response getDataSourceWithResponse(String dataSo * * @return a list of DataSources */ - public PagedIterable listDataSources() { - return listDataSources(null, Context.NONE); + public PagedIterable listDataSourceConnections() { + return listDataSourceConnections(null, Context.NONE); } /** @@ -143,9 +146,9 @@ public PagedIterable listDataSources() { * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return a response containing the list of DataSources. */ - public PagedIterable listDataSources(RequestOptions requestOptions, + public PagedIterable listDataSourceConnections(RequestOptions requestOptions, Context context) { - return new PagedIterable<>(asyncClient.listDataSources(requestOptions, context)); + return new PagedIterable<>(asyncClient.listDataSourceConnections(requestOptions, context)); } /** @@ -156,8 +159,8 @@ public PagedIterable listDataSources(RequestOptions req * @param context Additional context that is passed through the HTTP pipeline during the service call. * @return a response containing the list of DataSource names. */ - public PagedIterable listDataSourceNames(RequestOptions requestOptions, Context context) { - return new PagedIterable<>(asyncClient.listDataSourceNames(requestOptions, context)); + public PagedIterable listDataSourceConnectionNames(RequestOptions requestOptions, Context context) { + return new PagedIterable<>(asyncClient.listDataSourceConnectionNames(requestOptions, context)); } /** @@ -165,8 +168,8 @@ public PagedIterable listDataSourceNames(RequestOptions requestOptions, * * @return a list of DataSources names */ - public PagedIterable listDataSourceNames() { - return listDataSourceNames(null, Context.NONE); + public PagedIterable listDataSourceConnectionNames() { + return listDataSourceConnectionNames(null, Context.NONE); } /** @@ -174,14 +177,15 @@ public PagedIterable listDataSourceNames() { * * @param dataSourceName the name of the data source to be deleted */ - public void deleteDataSource(String dataSourceName) { - deleteDataSourceWithResponse(new SearchIndexerDataSource().setName(dataSourceName), false, null, Context.NONE); + public void deleteDataSourceConnection(String dataSourceName) { + deleteDataSourceConnectionWithResponse(new SearchIndexerDataSourceConnection().setName(dataSourceName), + false, null, Context.NONE); } /** * Delete a DataSource with Response * - * @param dataSource the {@link SearchIndexerDataSource} to be deleted. + * @param dataSource the {@link SearchIndexerDataSourceConnection} to be deleted. * @param onlyIfUnchanged {@code true} to delete if the {@code dataSource} is the same as the current service value. * {@code false} to always delete existing value. * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to @@ -189,10 +193,11 @@ public void deleteDataSource(String dataSourceName) { * @param context additional context that is passed through the HTTP pipeline during the service call * @return an empty response */ - public Response deleteDataSourceWithResponse(SearchIndexerDataSource dataSource, boolean onlyIfUnchanged, - RequestOptions requestOptions, Context context) { + public Response deleteDataSourceConnectionWithResponse(SearchIndexerDataSourceConnection dataSource, + boolean onlyIfUnchanged, RequestOptions requestOptions, Context context) { String etag = onlyIfUnchanged ? dataSource.getETag() : null; - return asyncClient.deleteDataSourceWithResponse(dataSource.getName(), etag, requestOptions, context).block(); + return asyncClient.deleteDataSourceConnectionWithResponse(dataSource.getName(), etag, requestOptions, context) + .block(); } /** diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerDataSources.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerDataSources.java index 743fb2cc453e..b211fed9f0f7 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerDataSources.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerDataSources.java @@ -6,19 +6,18 @@ import com.azure.core.util.CoreUtils; import com.azure.search.documents.indexes.models.DataChangeDetectionPolicy; import com.azure.search.documents.indexes.models.DataDeletionDetectionPolicy; -import com.azure.search.documents.indexes.models.DataSourceCredentials; import com.azure.search.documents.indexes.models.HighWaterMarkChangeDetectionPolicy; import com.azure.search.documents.indexes.models.SearchIndexerDataContainer; -import com.azure.search.documents.indexes.models.SearchIndexerDataSource; +import com.azure.search.documents.indexes.models.SearchIndexerDataSourceConnection; import com.azure.search.documents.indexes.models.SearchIndexerDataSourceType; /** - * Utility class that aids in the creation of {@link SearchIndexerDataSource SearchIndexerDataSources}. + * Utility class that aids in the creation of {@link SearchIndexerDataSourceConnection SearchIndexerDataSources}. */ public final class SearchIndexerDataSources { /** - * Creates a new {@link SearchIndexerDataSource} to connect to an Azure SQL database. + * Creates a new {@link SearchIndexerDataSourceConnection} to connect to an Azure SQL database. * * @param dataSourceName The name of the data source. * @param sqlConnectionString The connection string for the Azure SQL database. @@ -27,13 +26,13 @@ public final class SearchIndexerDataSources { * @param changeDetectionPolicy The change detection policy for the data source. Note that only high watermark * change detection is allowed for Azure SQL when deletion detection is enabled. * @param deletionDetectionPolicy Optional. The data deletion detection policy for the data source. - * @return A new Azure SQL {@link SearchIndexerDataSource} instance. + * @return A new Azure SQL {@link SearchIndexerDataSourceConnection} instance. * @throws IllegalArgumentException If {@code dataSourceName}, {@code sqlConnectionString}, or {@code * tableOrViewName} is null or empty. */ - public static SearchIndexerDataSource createFromAzureSql(String dataSourceName, String sqlConnectionString, - String tableOrViewName, String description, DataChangeDetectionPolicy changeDetectionPolicy, - DataDeletionDetectionPolicy deletionDetectionPolicy) { + public static SearchIndexerDataSourceConnection createFromAzureSql(String dataSourceName, + String sqlConnectionString, String tableOrViewName, String description, + DataChangeDetectionPolicy changeDetectionPolicy, DataDeletionDetectionPolicy deletionDetectionPolicy) { if (CoreUtils.isNullOrEmpty(dataSourceName)) { throw new IllegalArgumentException("'dataSourceName' cannot be null or empty."); } @@ -50,22 +49,23 @@ public static SearchIndexerDataSource createFromAzureSql(String dataSourceName, } /** - * Creates a new {@link SearchIndexerDataSource} to connect to an Azure SQL database. + * Creates a new {@link SearchIndexerDataSourceConnection} to connect to an Azure SQL database. * * @param dataSourceName The name of the data source. * @param sqlConnectionString The connection string for the Azure SQL database. * @param tableOrViewName The name of the table or view from which to read rows. - * @return A new Azure SQL {@link SearchIndexerDataSource} instance. + * @return A new Azure SQL {@link SearchIndexerDataSourceConnection} instance. * @throws IllegalArgumentException If {@code dataSourceName}, {@code sqlConnectionString}, or {@code * tableOrViewName} is null or empty. */ - public static SearchIndexerDataSource createFromAzureSql(String dataSourceName, String sqlConnectionString, - String tableOrViewName) { - return createFromAzureSql(dataSourceName, sqlConnectionString, tableOrViewName, null, null, null); + public static SearchIndexerDataSourceConnection createFromAzureSql(String dataSourceName, + String sqlConnectionString, String tableOrViewName) { + return createFromAzureSql(dataSourceName, sqlConnectionString, tableOrViewName, null, + null, null); } /** - * Creates a new {@link SearchIndexerDataSource} to connect to an Azure Blob container. + * Creates a new {@link SearchIndexerDataSourceConnection} to connect to an Azure Blob container. * * @param dataSourceName The name of the data source. * @param storageConnectionString The connection string for the Azure Storage account. The Storage connection string @@ -79,11 +79,11 @@ public static SearchIndexerDataSource createFromAzureSql(String dataSourceName, * is useful when blobs are organized into "virtual folders". * @param description Optional. Description of the data source * @param deletionDetectionPolicy Optional. The data deletion detection policy for the data source - * @return A new Azure Blob {@link SearchIndexerDataSource} instance. + * @return A new Azure Blob {@link SearchIndexerDataSourceConnection} instance. * @throws IllegalArgumentException If {@code dataSourceName}, {@code containerName} or {@code * storageConnectionString} is null or empty. */ - public static SearchIndexerDataSource createFromAzureBlobStorage(String dataSourceName, + public static SearchIndexerDataSourceConnection createFromAzureBlobStorage(String dataSourceName, String storageConnectionString, String containerName, String pathPrefix, String description, DataDeletionDetectionPolicy deletionDetectionPolicy) { if (CoreUtils.isNullOrEmpty(dataSourceName)) { @@ -101,7 +101,7 @@ public static SearchIndexerDataSource createFromAzureBlobStorage(String dataSour } /** - * Creates a new {@link SearchIndexerDataSource} to connect to an Azure Blob container. + * Creates a new {@link SearchIndexerDataSourceConnection} to connect to an Azure Blob container. * * @param dataSourceName The name of the data source. * @param storageConnectionString The connection string for the Azure Storage account. The Storage connection string @@ -111,17 +111,17 @@ public static SearchIndexerDataSource createFromAzureBlobStorage(String dataSour *

* Note: The connection string must use HTTPS. * @param containerName The name of the container from which to read blobs. - * @return A new Azure Blob {@link SearchIndexerDataSource} instance. + * @return A new Azure Blob {@link SearchIndexerDataSourceConnection} instance. * @throws IllegalArgumentException If {@code dataSourceName}, {@code containerName} or {@code * storageConnectionString} is null or empty. */ - public static SearchIndexerDataSource createFromAzureBlobStorage(String dataSourceName, + public static SearchIndexerDataSourceConnection createFromAzureBlobStorage(String dataSourceName, String storageConnectionString, String containerName) { return createFromAzureBlobStorage(dataSourceName, storageConnectionString, containerName, null, null, null); } /** - * Creates a new {@link SearchIndexerDataSource} to connect to an Azure Table. + * Creates a new {@link SearchIndexerDataSourceConnection} to connect to an Azure Table. * * @param dataSourceName The name of the data source. * @param storageConnectionString The connection string for the Azure Storage account. The Storage connection string @@ -134,11 +134,11 @@ public static SearchIndexerDataSource createFromAzureBlobStorage(String dataSour * @param query Optional. A query that is applied to the table when reading rows. * @param description Optional. Description of the data source * @param deletionDetectionPolicy Optional. The data deletion detection policy for the data source. - * @return A new Azure Table {@link SearchIndexerDataSource} instance. + * @return A new Azure Table {@link SearchIndexerDataSourceConnection} instance. * @throws IllegalArgumentException If {@code dataSourceName}, {@code tableName}, or {@code storageConnectionString} * is null or empty. */ - public static SearchIndexerDataSource createFromAzureTableStorage(String dataSourceName, + public static SearchIndexerDataSourceConnection createFromAzureTableStorage(String dataSourceName, String storageConnectionString, String tableName, String query, String description, DataDeletionDetectionPolicy deletionDetectionPolicy) { if (CoreUtils.isNullOrEmpty(dataSourceName)) { @@ -156,7 +156,7 @@ public static SearchIndexerDataSource createFromAzureTableStorage(String dataSou } /** - * Creates a new {@link SearchIndexerDataSource} to connect to an Azure Table. + * Creates a new {@link SearchIndexerDataSourceConnection} to connect to an Azure Table. * * @param dataSourceName The name of the data source. * @param storageConnectionString The connection string for the Azure Storage account. The Storage connection string @@ -166,17 +166,17 @@ public static SearchIndexerDataSource createFromAzureTableStorage(String dataSou *

* Note: The connection string must use HTTPS. * @param tableName The name of the Azure table from which to read rows. - * @return A new Azure Table {@link SearchIndexerDataSource} instance. + * @return A new Azure Table {@link SearchIndexerDataSourceConnection} instance. * @throws IllegalArgumentException If {@code dataSourceName}, {@code tableName}, or {@code storageConnectionString} * is null or empty. */ - public static SearchIndexerDataSource createFromAzureTableStorage(String dataSourceName, + public static SearchIndexerDataSourceConnection createFromAzureTableStorage(String dataSourceName, String storageConnectionString, String tableName) { return createFromAzureTableStorage(dataSourceName, storageConnectionString, tableName, null, null, null); } /** - * Creates a new {@link SearchIndexerDataSource} to connect to a Cosmos database. + * Creates a new {@link SearchIndexerDataSourceConnection} to connect to a Cosmos database. * * @param dataSourceName The name of the data source. * @param cosmosConnectionString The connection string for the Cosmos database. It must follow this format: @@ -188,13 +188,13 @@ public static SearchIndexerDataSource createFromAzureTableStorage(String dataSou * @param useChangeDetection Optional. Indicates whether to use change detection when indexing. Default is true. * @param description Optional. Description of the data source * @param deletionDetectionPolicy Optional. The data deletion detection policy for the data source. - * @return A new Cosmos {@link SearchIndexerDataSource} instance. + * @return A new Cosmos {@link SearchIndexerDataSourceConnection} instance. * @throws IllegalArgumentException If {@code dataSourceName}, {@code collectionName}, or {@code * cosmosConnectionString} is null or empty. */ - public static SearchIndexerDataSource createFromCosmos(String dataSourceName, String cosmosConnectionString, - String collectionName, String query, Boolean useChangeDetection, String description, - DataDeletionDetectionPolicy deletionDetectionPolicy) { + public static SearchIndexerDataSourceConnection createFromCosmos(String dataSourceName, + String cosmosConnectionString, String collectionName, String query, Boolean useChangeDetection, + String description, DataDeletionDetectionPolicy deletionDetectionPolicy) { if (CoreUtils.isNullOrEmpty(dataSourceName)) { throw new IllegalArgumentException("'dataSourceName' cannot be null or empty."); } @@ -215,7 +215,7 @@ public static SearchIndexerDataSource createFromCosmos(String dataSourceName, St } /** - * Creates a new {@link SearchIndexerDataSource} to connect to a Cosmos database. + * Creates a new {@link SearchIndexerDataSourceConnection} to connect to a Cosmos database. * * @param dataSourceName The name of the data source. * @param cosmosConnectionString The connection string for the Cosmos database. It must follow this format: @@ -224,18 +224,19 @@ public static SearchIndexerDataSource createFromCosmos(String dataSourceName, St * database name]"} * @param collectionName The name of the collection from which to read documents * @param useChangeDetection Optional. Indicates whether to use change detection when indexing. Default is true. - * @return A new Cosmos {@link SearchIndexerDataSource} instance. + * @return A new Cosmos {@link SearchIndexerDataSourceConnection} instance. * @throws IllegalArgumentException If {@code dataSourceName}, {@code collectionName}, or {@code * cosmosConnectionString} is null or empty. */ - public static SearchIndexerDataSource createFromCosmos(String dataSourceName, String cosmosConnectionString, - String collectionName, Boolean useChangeDetection) { + public static SearchIndexerDataSourceConnection createFromCosmos(String dataSourceName, + String cosmosConnectionString, String collectionName, Boolean useChangeDetection) { return createFromCosmos(dataSourceName, cosmosConnectionString, collectionName, null, useChangeDetection, null, null); } /** - * Creates a new {@link SearchIndexerDataSource} to connect to a Cosmos database with change detection set to true. + * Creates a new {@link SearchIndexerDataSourceConnection} to connect to a Cosmos database with change detection + * set to true. * * @param dataSourceName The name of the data source. * @param cosmosConnectionString The connection string for the Cosmos database. It must follow this format: @@ -243,25 +244,27 @@ public static SearchIndexerDataSource createFromCosmos(String dataSourceName, St * {@code AccountName|AccountEndpoint=[your account name or endpoint]; AccountKey=[your account key];Database=[your * database name]"} * @param collectionName The name of the collection from which to read documents - * @return A new Cosmos {@link SearchIndexerDataSource} instance. + * @return A new Cosmos {@link SearchIndexerDataSourceConnection} instance. * @throws IllegalArgumentException If {@code dataSourceName}, {@code collectionName}, or {@code * cosmosConnectionString} is null or empty. */ - public static SearchIndexerDataSource createFromCosmos(String dataSourceName, String cosmosConnectionString, - String collectionName) { - return createFromCosmos(dataSourceName, cosmosConnectionString, collectionName, null, true, null, null); + public static SearchIndexerDataSourceConnection createFromCosmos(String dataSourceName, + String cosmosConnectionString, String collectionName) { + return createFromCosmos(dataSourceName, cosmosConnectionString, collectionName, null, + true, null, null); } /* * Helper method that creates a generic SearchIndexerDataSource. */ - private static SearchIndexerDataSource createSearchIndexerDataSource(String name, SearchIndexerDataSourceType type, - String connectionString, String dataSourceName, String dataSourceQuery, String description, - DataChangeDetectionPolicy dataChangeDetectionPolicy, DataDeletionDetectionPolicy dataDeletionDetectionPolicy) { - return new SearchIndexerDataSource() + private static SearchIndexerDataSourceConnection createSearchIndexerDataSource(String name, + SearchIndexerDataSourceType type, String connectionString, String dataSourceName, String dataSourceQuery, + String description, DataChangeDetectionPolicy dataChangeDetectionPolicy, + DataDeletionDetectionPolicy dataDeletionDetectionPolicy) { + return new SearchIndexerDataSourceConnection() .setName(name) .setType(type) - .setCredentials(new DataSourceCredentials().setConnectionString(connectionString)) + .setConnectionString(connectionString) .setContainer(new SearchIndexerDataContainer().setName(dataSourceName).setQuery(dataSourceQuery)) .setDescription(description) .setDataChangeDetectionPolicy(dataChangeDetectionPolicy) diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/AzureActiveDirectoryApplicationCredentials.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/AzureActiveDirectoryApplicationCredentials.java deleted file mode 100644 index fc716a09c74e..000000000000 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/AzureActiveDirectoryApplicationCredentials.java +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.search.documents.indexes.models; - -import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Credentials of a registered application created for your search service, - * used for authenticated access to the encryption keys stored in Azure Key - * Vault. - */ -@Fluent -public final class AzureActiveDirectoryApplicationCredentials { - /* - * An AAD Application ID that was granted the required access permissions - * to the Azure Key Vault that is to be used when encrypting your data at - * rest. The Application ID should not be confused with the Object ID for - * your AAD Application. - */ - @JsonProperty(value = "applicationId", required = true) - private String applicationId; - - /* - * The authentication key of the specified AAD application. - */ - @JsonProperty(value = "applicationSecret") - private String applicationSecret; - - /** - * Get the applicationId property: An AAD Application ID that was granted - * the required access permissions to the Azure Key Vault that is to be - * used when encrypting your data at rest. The Application ID should not be - * confused with the Object ID for your AAD Application. - * - * @return the applicationId value. - */ - public String getApplicationId() { - return this.applicationId; - } - - /** - * Set the applicationId property: An AAD Application ID that was granted - * the required access permissions to the Azure Key Vault that is to be - * used when encrypting your data at rest. The Application ID should not be - * confused with the Object ID for your AAD Application. - * - * @param applicationId the applicationId value to set. - * @return the AzureActiveDirectoryApplicationCredentials object itself. - */ - public AzureActiveDirectoryApplicationCredentials setApplicationId(String applicationId) { - this.applicationId = applicationId; - return this; - } - - /** - * Get the applicationSecret property: The authentication key of the - * specified AAD application. - * - * @return the applicationSecret value. - */ - public String getApplicationSecret() { - return this.applicationSecret; - } - - /** - * Set the applicationSecret property: The authentication key of the - * specified AAD application. - * - * @param applicationSecret the applicationSecret value to set. - * @return the AzureActiveDirectoryApplicationCredentials object itself. - */ - public AzureActiveDirectoryApplicationCredentials setApplicationSecret(String applicationSecret) { - this.applicationSecret = applicationSecret; - return this; - } -} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/DataSourceCredentials.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/DataSourceCredentials.java deleted file mode 100644 index cc5a6ca2fc25..000000000000 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/DataSourceCredentials.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.search.documents.indexes.models; - -import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Represents credentials that can be used to connect to a datasource. - */ -@Fluent -public final class DataSourceCredentials { - /* - * The connection string for the datasource. - */ - @JsonProperty(value = "connectionString") - private String connectionString; - - /** - * Get the connectionString property: The connection string for the - * datasource. - * - * @return the connectionString value. - */ - public String getConnectionString() { - return this.connectionString; - } - - /** - * Set the connectionString property: The connection string for the - * datasource. - * - * @param connectionString the connectionString value to set. - * @return the DataSourceCredentials object itself. - */ - public DataSourceCredentials setConnectionString(String connectionString) { - this.connectionString = connectionString; - return this; - } -} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexerDataSource.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexerDataSourceConnection.java similarity index 80% rename from sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexerDataSource.java rename to sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexerDataSourceConnection.java index dc75e76f7630..211b39bf9173 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexerDataSource.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexerDataSourceConnection.java @@ -11,7 +11,7 @@ * indexer. */ @Fluent -public final class SearchIndexerDataSource { +public final class SearchIndexerDataSourceConnection { /* * The name of the datasource. */ @@ -32,10 +32,10 @@ public final class SearchIndexerDataSource { private SearchIndexerDataSourceType type; /* - * Credentials for the datasource. + * The connection string for the datasource. */ - @JsonProperty(value = "credentials", required = true) - private DataSourceCredentials credentials; + @JsonProperty(value = "connectionString") + private String connectionString; /* * The data container for the datasource. @@ -76,7 +76,7 @@ public String getName() { * @param name the name value to set. * @return the SearchIndexerDataSource object itself. */ - public SearchIndexerDataSource setName(String name) { + public SearchIndexerDataSourceConnection setName(String name) { this.name = name; return this; } @@ -96,7 +96,7 @@ public String getDescription() { * @param description the description value to set. * @return the SearchIndexerDataSource object itself. */ - public SearchIndexerDataSource setDescription(String description) { + public SearchIndexerDataSourceConnection setDescription(String description) { this.description = description; return this; } @@ -118,28 +118,30 @@ public SearchIndexerDataSourceType getType() { * @param type the type value to set. * @return the SearchIndexerDataSource object itself. */ - public SearchIndexerDataSource setType(SearchIndexerDataSourceType type) { + public SearchIndexerDataSourceConnection setType(SearchIndexerDataSourceType type) { this.type = type; return this; } /** - * Get the credentials property: Credentials for the datasource. + * Get the connectionString property: The connection string for the + * datasource. * - * @return the credentials value. + * @return the connectionString value. */ - public DataSourceCredentials getCredentials() { - return this.credentials; + public String getConnectionString() { + return this.connectionString; } /** - * Set the credentials property: Credentials for the datasource. + * Set the connectionString property: The connection string for the + * datasource. * - * @param credentials the credentials value to set. + * @param connectionString the connectionString value to set. * @return the SearchIndexerDataSource object itself. */ - public SearchIndexerDataSource setCredentials(DataSourceCredentials credentials) { - this.credentials = credentials; + public SearchIndexerDataSourceConnection setConnectionString(String connectionString) { + this.connectionString = connectionString; return this; } @@ -158,7 +160,7 @@ public SearchIndexerDataContainer getContainer() { * @param container the container value to set. * @return the SearchIndexerDataSource object itself. */ - public SearchIndexerDataSource setContainer(SearchIndexerDataContainer container) { + public SearchIndexerDataSourceConnection setContainer(SearchIndexerDataContainer container) { this.container = container; return this; } @@ -181,7 +183,8 @@ public DataChangeDetectionPolicy getDataChangeDetectionPolicy() { * set. * @return the SearchIndexerDataSource object itself. */ - public SearchIndexerDataSource setDataChangeDetectionPolicy(DataChangeDetectionPolicy dataChangeDetectionPolicy) { + public SearchIndexerDataSourceConnection setDataChangeDetectionPolicy( + DataChangeDetectionPolicy dataChangeDetectionPolicy) { this.dataChangeDetectionPolicy = dataChangeDetectionPolicy; return this; } @@ -204,7 +207,7 @@ public DataDeletionDetectionPolicy getDataDeletionDetectionPolicy() { * to set. * @return the SearchIndexerDataSource object itself. */ - public SearchIndexerDataSource setDataDeletionDetectionPolicy( + public SearchIndexerDataSourceConnection setDataDeletionDetectionPolicy( DataDeletionDetectionPolicy dataDeletionDetectionPolicy) { this.dataDeletionDetectionPolicy = dataDeletionDetectionPolicy; return this; @@ -225,7 +228,7 @@ public String getETag() { * @param eTag the eTag value to set. * @return the SearchIndexerDataSource object itself. */ - public SearchIndexerDataSource setETag(String eTag) { + public SearchIndexerDataSourceConnection setETag(String eTag) { this.eTag = eTag; return this; } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchResourceEncryptionKey.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchResourceEncryptionKey.java index cf104b24d0bd..e6b6e45b693b 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchResourceEncryptionKey.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchResourceEncryptionKey.java @@ -36,11 +36,19 @@ public final class SearchResourceEncryptionKey { private String vaultUri; /* - * Optional Azure Active Directory credentials used for accessing your - * Azure Key Vault. Not required if using managed identity instead. + * An AAD Application ID that was granted the required access permissions + * to the Azure Key Vault that is to be used when encrypting your data at + * rest. The Application ID should not be confused with the Object ID for + * your AAD Application. */ - @JsonProperty(value = "accessCredentials") - private AzureActiveDirectoryApplicationCredentials accessCredentials; + @JsonProperty(value = "applicationId", required = true) + private String applicationId; + + /* + * The authentication key of the specified AAD application. + */ + @JsonProperty(value = "applicationSecret") + private String applicationSecret; /** * Get the keyName property: The name of your Azure Key Vault key to be @@ -113,27 +121,50 @@ public SearchResourceEncryptionKey setVaultUri(String vaultUri) { } /** - * Get the accessCredentials property: Optional Azure Active Directory - * credentials used for accessing your Azure Key Vault. Not required if - * using managed identity instead. + * Get the applicationId property: An AAD Application ID that was granted + * the required access permissions to the Azure Key Vault that is to be + * used when encrypting your data at rest. The Application ID should not be + * confused with the Object ID for your AAD Application. + * + * @return the applicationId value. + */ + public String getApplicationId() { + return this.applicationId; + } + + /** + * Set the applicationId property: An AAD Application ID that was granted + * the required access permissions to the Azure Key Vault that is to be + * used when encrypting your data at rest. The Application ID should not be + * confused with the Object ID for your AAD Application. + * + * @param applicationId the applicationId value to set. + * @return the SearchResourceEncryptionKey object itself. + */ + public SearchResourceEncryptionKey setApplicationId(String applicationId) { + this.applicationId = applicationId; + return this; + } + + /** + * Get the applicationSecret property: The authentication key of the + * specified AAD application. * - * @return the accessCredentials value. + * @return the applicationSecret value. */ - public AzureActiveDirectoryApplicationCredentials getAccessCredentials() { - return this.accessCredentials; + public String getApplicationSecret() { + return this.applicationSecret; } /** - * Set the accessCredentials property: Optional Azure Active Directory - * credentials used for accessing your Azure Key Vault. Not required if - * using managed identity instead. + * Set the applicationSecret property: The authentication key of the + * specified AAD application. * - * @param accessCredentials the accessCredentials value to set. + * @param applicationSecret the applicationSecret value to set. * @return the SearchResourceEncryptionKey object itself. */ - public SearchResourceEncryptionKey setAccessCredentials( - AzureActiveDirectoryApplicationCredentials accessCredentials) { - this.accessCredentials = accessCredentials; + public SearchResourceEncryptionKey setApplicationSecret(String applicationSecret) { + this.applicationSecret = applicationSecret; return this; } } diff --git a/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/DataSourceExample.java b/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/DataSourceExample.java index 2e34c997d033..16cca52cd740 100644 --- a/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/DataSourceExample.java +++ b/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/DataSourceExample.java @@ -7,10 +7,9 @@ import com.azure.core.http.rest.PagedIterable; import com.azure.core.util.Configuration; import com.azure.search.documents.indexes.models.DataChangeDetectionPolicy; -import com.azure.search.documents.indexes.models.DataSourceCredentials; import com.azure.search.documents.indexes.models.HighWaterMarkChangeDetectionPolicy; import com.azure.search.documents.indexes.models.SearchIndexerDataContainer; -import com.azure.search.documents.indexes.models.SearchIndexerDataSource; +import com.azure.search.documents.indexes.models.SearchIndexerDataSourceConnection; import com.azure.search.documents.indexes.models.SearchIndexerDataSourceType; import java.util.Collection; @@ -54,8 +53,8 @@ public static void main(String[] args) { /* * Get all existing data sources; list should include the ones we just created. * */ - PagedIterable dataSources = client.listDataSources(); - for (SearchIndexerDataSource dataSource : dataSources) { + PagedIterable dataSources = client.listDataSourceConnections(); + for (SearchIndexerDataSourceConnection dataSource : dataSources) { if (names.contains(dataSource.getName())) { System.out.println(String.format("Found data source %s of type %s", dataSource.getName(), dataSource.getType().toString())); @@ -72,20 +71,19 @@ public static void main(String[] args) { private static void deleteDataSource(SearchIndexerClient client, String dataSourceName) { try { - client.deleteDataSource(dataSourceName); + client.deleteDataSourceConnection(dataSourceName); } catch (Exception ex) { System.err.println(ex.toString()); } } - private static SearchIndexerDataSource createSampleDatasource(SearchIndexerDataSourceType type, + private static SearchIndexerDataSourceConnection createSampleDatasource(SearchIndexerDataSourceType type, String connectionString, SearchIndexerDataContainer container, DataChangeDetectionPolicy dataChangeDetectionPolicy) { - return new SearchIndexerDataSource() + return new SearchIndexerDataSourceConnection() .setName(generateDataSourceName()) .setType(type) - .setCredentials(new DataSourceCredentials() - .setConnectionString(connectionString)) + .setConnectionString(connectionString) .setContainer(container) .setDataChangeDetectionPolicy(dataChangeDetectionPolicy); } @@ -97,10 +95,10 @@ private static String createDataSource( SearchIndexerDataContainer container, DataChangeDetectionPolicy dataChangeDetectionPolicy) { - SearchIndexerDataSource dataSource = createSampleDatasource(type, connectionString, container, + SearchIndexerDataSourceConnection dataSource = createSampleDatasource(type, connectionString, container, dataChangeDetectionPolicy); try { - client.createOrUpdateDataSource(dataSource); + client.createOrUpdateDataSourceConnection(dataSource); } catch (Exception ex) { System.err.println(ex.toString()); } diff --git a/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/LifecycleSetupExample.java b/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/LifecycleSetupExample.java index 1fb4baf70a75..54f3d2ad304d 100644 --- a/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/LifecycleSetupExample.java +++ b/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/LifecycleSetupExample.java @@ -5,7 +5,6 @@ import com.azure.core.credential.AzureKeyCredential; import com.azure.core.util.Configuration; -import com.azure.search.documents.indexes.models.DataSourceCredentials; import com.azure.search.documents.indexes.models.EntityRecognitionSkill; import com.azure.search.documents.indexes.models.HighWaterMarkChangeDetectionPolicy; import com.azure.search.documents.indexes.models.IndexingSchedule; @@ -17,7 +16,7 @@ import com.azure.search.documents.indexes.models.SearchIndex; import com.azure.search.documents.indexes.models.SearchIndexer; import com.azure.search.documents.indexes.models.SearchIndexerDataContainer; -import com.azure.search.documents.indexes.models.SearchIndexerDataSource; +import com.azure.search.documents.indexes.models.SearchIndexerDataSourceConnection; import com.azure.search.documents.indexes.models.SearchIndexerDataSourceType; import com.azure.search.documents.indexes.models.SearchIndexerSkill; import com.azure.search.documents.indexes.models.SearchIndexerSkillset; @@ -56,7 +55,8 @@ public static void main(String[] args) { SearchIndexClient indexClient = createIndexClient(); SearchIndexerClient indexerClient = createIndexerClient(); // Create a data source for a Cosmos DB database - SearchIndexerDataSource dataSource = createCosmosDataSource(indexerClient); + SearchIndexerDataSourceConnection dataSource = createCosmosDataSource(indexerClient); + System.out.println("Created DataSource " + dataSource.getName()); // Create an index @@ -102,7 +102,7 @@ private static void updateIndexerSchedule(SearchIndexerClient client, SearchInde client.createOrUpdateIndexer(indexer); } - private static SearchIndexer createIndexer(SearchIndexerClient client, SearchIndexerDataSource dataSource, + private static SearchIndexer createIndexer(SearchIndexerClient client, SearchIndexerDataSourceConnection dataSource, SearchIndexerSkillset skillset, SearchIndex index) { SearchIndexer indexer = new SearchIndexer() .setName(INDEXER_NAME) @@ -194,21 +194,20 @@ private static SearchIndex createIndex(SearchIndexClient client) { return client.createOrUpdateIndex(index); } - private static SearchIndexerDataSource createCosmosDataSource(SearchIndexerClient client) { + private static SearchIndexerDataSourceConnection createCosmosDataSource(SearchIndexerClient client) { SearchIndexerDataContainer dataContainer = new SearchIndexerDataContainer().setName(COSMOS_COLLECTION_NAME); HighWaterMarkChangeDetectionPolicy highWaterMarkChangeDetectionPolicy = new HighWaterMarkChangeDetectionPolicy().setHighWaterMarkColumnName("_ts"); - SearchIndexerDataSource dataSource = new SearchIndexerDataSource() + SearchIndexerDataSourceConnection dataSource = new SearchIndexerDataSourceConnection() .setName(DATASOURCE_NAME) .setType(SearchIndexerDataSourceType.COSMOS_DB) - .setCredentials(new DataSourceCredentials() - .setConnectionString(COSMOS_CONNECTION_STRING)) + .setConnectionString(COSMOS_CONNECTION_STRING) .setContainer(dataContainer) .setDataChangeDetectionPolicy(highWaterMarkChangeDetectionPolicy); - return client.createOrUpdateDataSource(dataSource); + return client.createOrUpdateDataSourceConnection(dataSource); } diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchTestBase.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchTestBase.java index c89b376e54c2..2145adf7b2cc 100644 --- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchTestBase.java +++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchTestBase.java @@ -28,7 +28,7 @@ import com.azure.search.documents.indexes.models.SearchField; import com.azure.search.documents.indexes.models.SearchFieldDataType; import com.azure.search.documents.indexes.models.SearchIndex; -import com.azure.search.documents.indexes.models.SearchIndexerDataSource; +import com.azure.search.documents.indexes.models.SearchIndexerDataSourceConnection; import com.azure.search.documents.indexes.models.SoftDeleteColumnDeletionDetectionPolicy; import com.azure.search.documents.indexes.models.Suggester; import com.azure.search.documents.indexes.models.TagScoringFunction; @@ -456,18 +456,18 @@ protected SearchIndex createTestIndex() { .setSourceFields(Collections.singletonList("HotelName")))); } - protected SearchIndexerDataSource createTestSqlDataSourceObject() { + protected SearchIndexerDataSourceConnection createTestSqlDataSourceObject() { return createTestSqlDataSourceObject(null, null); } - protected SearchIndexerDataSource createTestSqlDataSourceObject( + protected SearchIndexerDataSourceConnection createTestSqlDataSourceObject( DataDeletionDetectionPolicy dataDeletionDetectionPolicy, DataChangeDetectionPolicy dataChangeDetectionPolicy) { return SearchIndexerDataSources.createFromAzureSql(testResourceNamer.randomName(SQL_DATASOURCE_NAME, 32), AZURE_SQL_CONN_STRING_READONLY_PLAYGROUND, "GeoNamesRI", FAKE_DESCRIPTION, dataChangeDetectionPolicy, dataDeletionDetectionPolicy); } - protected SearchIndexerDataSource createBlobDataSource() { + protected SearchIndexerDataSourceConnection createBlobDataSource() { String storageConnectionString = Configuration.getGlobalConfiguration() .get("SEARCH_STORAGE_CONNECTION_STRING", "connectionString"); String blobContainerName = Configuration.getGlobalConfiguration() diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/DataSourceSyncTests.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/DataSourceSyncTests.java index e9defa880e16..272b2d8999f0 100644 --- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/DataSourceSyncTests.java +++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/DataSourceSyncTests.java @@ -10,10 +10,9 @@ import com.azure.search.documents.SearchTestBase; import com.azure.search.documents.TestHelpers; import com.azure.search.documents.indexes.models.DataDeletionDetectionPolicy; -import com.azure.search.documents.indexes.models.DataSourceCredentials; import com.azure.search.documents.indexes.models.HighWaterMarkChangeDetectionPolicy; import com.azure.search.documents.indexes.models.SearchIndexerDataContainer; -import com.azure.search.documents.indexes.models.SearchIndexerDataSource; +import com.azure.search.documents.indexes.models.SearchIndexerDataSourceConnection; import com.azure.search.documents.indexes.models.SearchIndexerDataSourceType; import com.azure.search.documents.indexes.models.SoftDeleteColumnDeletionDetectionPolicy; import com.azure.search.documents.indexes.models.SqlIntegratedChangeTrackingPolicy; @@ -55,22 +54,22 @@ protected void beforeTest() { protected void afterTest() { super.afterTest(); for (String dataSource : dataSourcesToDelete) { - client.deleteDataSource(dataSource); + client.deleteDataSourceConnection(dataSource); } } @Test public void canCreateAndListDataSources() { - SearchIndexerDataSource dataSource1 = createTestBlobDataSource(null); - SearchIndexerDataSource dataSource2 = createTestSqlDataSourceObject(); + SearchIndexerDataSourceConnection dataSource1 = createTestBlobDataSource(null); + SearchIndexerDataSourceConnection dataSource2 = createTestSqlDataSourceObject(); - client.createOrUpdateDataSource(dataSource1); + client.createOrUpdateDataSourceConnection(dataSource1); dataSourcesToDelete.add(dataSource1.getName()); - client.createOrUpdateDataSource(dataSource2); + client.createOrUpdateDataSourceConnection(dataSource2); dataSourcesToDelete.add(dataSource2.getName()); - Iterator results = client.listDataSources().iterator(); + Iterator results = client.listDataSourceConnections().iterator(); assertDataSourceEquals(dataSource1, results.next()); assertDataSourceEquals(dataSource2, results.next()); @@ -79,15 +78,15 @@ public void canCreateAndListDataSources() { @Test public void canCreateAndListDataSourcesWithResponse() { - SearchIndexerDataSource dataSource1 = createTestBlobDataSource(null); - SearchIndexerDataSource dataSource2 = createTestSqlDataSourceObject(); + SearchIndexerDataSourceConnection dataSource1 = createTestBlobDataSource(null); + SearchIndexerDataSourceConnection dataSource2 = createTestSqlDataSourceObject(); - client.createOrUpdateDataSourceWithResponse(dataSource1, false, new RequestOptions(), Context.NONE); + client.createOrUpdateDataSourceConnectionWithResponse(dataSource1, false, new RequestOptions(), Context.NONE); dataSourcesToDelete.add(dataSource1.getName()); - client.createOrUpdateDataSourceWithResponse(dataSource2, false, new RequestOptions(), Context.NONE); + client.createOrUpdateDataSourceConnectionWithResponse(dataSource2, false, new RequestOptions(), Context.NONE); dataSourcesToDelete.add(dataSource2.getName()); - Iterator results = client.listDataSourceNames(new RequestOptions(), Context.NONE).iterator(); + Iterator results = client.listDataSourceConnectionNames(new RequestOptions(), Context.NONE).iterator(); assertEquals(dataSource1.getName(), results.next()); assertEquals(dataSource2.getName(), results.next()); assertFalse(results.hasNext()); @@ -95,39 +94,39 @@ public void canCreateAndListDataSourcesWithResponse() { @Test public void canCreateAndDeleteDatasource() { - SearchIndexerDataSource dataSource = createTestBlobDataSource(null); - client.deleteDataSource(dataSource.getName()); + SearchIndexerDataSourceConnection dataSource = createTestBlobDataSource(null); + client.deleteDataSourceConnection(dataSource.getName()); - assertThrows(HttpResponseException.class, () -> client.getDataSource(dataSource.getName())); + assertThrows(HttpResponseException.class, () -> client.getDataSourceConnection(dataSource.getName())); } @Test public void deleteDataSourceIsIdempotent() { - SearchIndexerDataSource dataSource = createTestBlobDataSource(null); + SearchIndexerDataSourceConnection dataSource = createTestBlobDataSource(null); // Try to delete before the data source exists, expect a NOT FOUND return status code - Response result = client.deleteDataSourceWithResponse(dataSource, false, generateRequestOptions(), + Response result = client.deleteDataSourceConnectionWithResponse(dataSource, false, generateRequestOptions(), Context.NONE); assertEquals(HttpURLConnection.HTTP_NOT_FOUND, result.getStatusCode()); // Create the data source - client.createOrUpdateDataSource(dataSource); + client.createOrUpdateDataSourceConnection(dataSource); // Delete twice, expect the first to succeed (with NO CONTENT status code) and the second to return NOT FOUND - result = client.deleteDataSourceWithResponse(dataSource, false, generateRequestOptions(), Context.NONE); + result = client.deleteDataSourceConnectionWithResponse(dataSource, false, generateRequestOptions(), Context.NONE); assertEquals(HttpURLConnection.HTTP_NO_CONTENT, result.getStatusCode()); // Again, expect to fail - result = client.deleteDataSourceWithResponse(dataSource, false, generateRequestOptions(), Context.NONE); + result = client.deleteDataSourceConnectionWithResponse(dataSource, false, generateRequestOptions(), Context.NONE); assertEquals(HttpURLConnection.HTTP_NOT_FOUND, result.getStatusCode()); } @Test public void createDataSourceFailsWithUsefulMessageOnUserError() { - SearchIndexerDataSource dataSource = createTestSqlDataSourceObject(); + SearchIndexerDataSourceConnection dataSource = createTestSqlDataSourceObject(); dataSource.setType(SearchIndexerDataSourceType.fromString("thistypedoesnotexist")); assertHttpResponseException( - () -> client.createOrUpdateDataSource(dataSource), + () -> client.createOrUpdateDataSourceConnection(dataSource), HttpURLConnection.HTTP_BAD_REQUEST, "Data source type 'thistypedoesnotexist' is not supported" ); @@ -135,13 +134,13 @@ public void createDataSourceFailsWithUsefulMessageOnUserError() { @Test public void canUpdateDataSource() { - SearchIndexerDataSource initial = createTestSqlDataSourceObject(); + SearchIndexerDataSourceConnection initial = createTestSqlDataSourceObject(); // Create the data source - client.createOrUpdateDataSource(initial); + client.createOrUpdateDataSourceConnection(initial); dataSourcesToDelete.add(initial.getName()); - SearchIndexerDataSource updatedExpected = createTestSqlDataSourceObject() + SearchIndexerDataSourceConnection updatedExpected = createTestSqlDataSourceObject() .setName(initial.getName()) .setContainer(new SearchIndexerDataContainer().setName("somethingdifferent")) .setDescription("somethingdifferent") @@ -150,18 +149,18 @@ public void canUpdateDataSource() { .setDataDeletionDetectionPolicy(new SoftDeleteColumnDeletionDetectionPolicy() .setSoftDeleteColumnName("isDeleted")); - SearchIndexerDataSource updatedActual = client.createOrUpdateDataSource(updatedExpected); + SearchIndexerDataSourceConnection updatedActual = client.createOrUpdateDataSourceConnection(updatedExpected); - updatedExpected.getCredentials().setConnectionString(null); // Create doesn't return connection strings. + updatedExpected.setConnectionString(null); // Create doesn't return connection strings. TestHelpers.assertObjectEquals(updatedExpected, updatedActual, false, "etag", "@odata.etag"); } @Test public void createOrUpdateDatasourceIfNotExistsSucceedsOnNoResource() { - SearchIndexerDataSource dataSource = createTestBlobDataSource(null); + SearchIndexerDataSourceConnection dataSource = createTestBlobDataSource(null); dataSourcesToDelete.add(dataSource.getName()); - SearchIndexerDataSource response = client.createOrUpdateDataSourceWithResponse(dataSource, true, null, Context.NONE) + SearchIndexerDataSourceConnection response = client.createOrUpdateDataSourceConnectionWithResponse(dataSource, true, null, Context.NONE) .getValue(); assertFalse(CoreUtils.isNullOrEmpty(response.getETag())); @@ -169,16 +168,16 @@ public void createOrUpdateDatasourceIfNotExistsSucceedsOnNoResource() { @Test public void deleteDataSourceIfExistsWorksOnlyWhenResourceExists() { - SearchIndexerDataSource dataSource = createTestBlobDataSource(null); + SearchIndexerDataSourceConnection dataSource = createTestBlobDataSource(null); dataSourcesToDelete.add(dataSource.getName()); - SearchIndexerDataSource response = client.createOrUpdateDataSourceWithResponse(dataSource, false, null, Context.NONE) + SearchIndexerDataSourceConnection response = client.createOrUpdateDataSourceConnectionWithResponse(dataSource, false, null, Context.NONE) .getValue(); - client.deleteDataSourceWithResponse(response, true, null, Context.NONE); + client.deleteDataSourceConnectionWithResponse(response, true, null, Context.NONE); try { - client.deleteDataSourceWithResponse(response, true, null, Context.NONE); + client.deleteDataSourceConnectionWithResponse(response, true, null, Context.NONE); fail("Second call to delete with specified ETag should have failed due to non existent data source."); } catch (HttpResponseException ex) { assertEquals(HttpURLConnection.HTTP_PRECON_FAILED, ex.getResponse().getStatusCode()); @@ -187,34 +186,34 @@ public void deleteDataSourceIfExistsWorksOnlyWhenResourceExists() { @Test public void deleteDataSourceIfNotChangedWorksOnlyOnCurrentResource() { - SearchIndexerDataSource dataSource = createTestBlobDataSource(null); + SearchIndexerDataSourceConnection dataSource = createTestBlobDataSource(null); - SearchIndexerDataSource stale = client.createOrUpdateDataSourceWithResponse(dataSource, false, null, Context.NONE) + SearchIndexerDataSourceConnection stale = client.createOrUpdateDataSourceConnectionWithResponse(dataSource, false, null, Context.NONE) .getValue(); - SearchIndexerDataSource current = client.createOrUpdateDataSourceWithResponse(stale, false, null, Context.NONE) + SearchIndexerDataSourceConnection current = client.createOrUpdateDataSourceConnectionWithResponse(stale, false, null, Context.NONE) .getValue(); try { - client.deleteDataSourceWithResponse(stale, true, null, Context.NONE); + client.deleteDataSourceConnectionWithResponse(stale, true, null, Context.NONE); fail("Delete specifying a stale ETag should have failed due to precondition."); } catch (HttpResponseException ex) { assertEquals(HttpURLConnection.HTTP_PRECON_FAILED, ex.getResponse().getStatusCode()); } - client.deleteDataSourceWithResponse(current, true, null, Context.NONE); + client.deleteDataSourceConnectionWithResponse(current, true, null, Context.NONE); } @Test public void updateDataSourceIfExistsSucceedsOnExistingResource() { - SearchIndexerDataSource dataSource = createTestBlobDataSource(null); + SearchIndexerDataSourceConnection dataSource = createTestBlobDataSource(null); dataSourcesToDelete.add(dataSource.getName()); - SearchIndexerDataSource original = client.createOrUpdateDataSourceWithResponse(dataSource, false, null, Context.NONE) + SearchIndexerDataSourceConnection original = client.createOrUpdateDataSourceConnectionWithResponse(dataSource, false, null, Context.NONE) .getValue(); String originalETag = original.getETag(); - SearchIndexerDataSource updated = client.createOrUpdateDataSourceWithResponse(original.setDescription("an update"), false, + SearchIndexerDataSourceConnection updated = client.createOrUpdateDataSourceConnectionWithResponse(original.setDescription("an update"), false, null, Context.NONE) .getValue(); String updatedETag = updated.getETag(); @@ -225,20 +224,20 @@ public void updateDataSourceIfExistsSucceedsOnExistingResource() { @Test public void updateDataSourceIfNotChangedFailsWhenResourceChanged() { - SearchIndexerDataSource dataSource = createTestBlobDataSource(null); + SearchIndexerDataSourceConnection dataSource = createTestBlobDataSource(null); dataSourcesToDelete.add(dataSource.getName()); - SearchIndexerDataSource original = client.createOrUpdateDataSourceWithResponse(dataSource, false, null, Context.NONE) + SearchIndexerDataSourceConnection original = client.createOrUpdateDataSourceConnectionWithResponse(dataSource, false, null, Context.NONE) .getValue(); String originalETag = original.getETag(); - SearchIndexerDataSource updated = client.createOrUpdateDataSourceWithResponse(original.setDescription("an update"), false, + SearchIndexerDataSourceConnection updated = client.createOrUpdateDataSourceConnectionWithResponse(original.setDescription("an update"), false, null, Context.NONE) .getValue(); String updatedETag = updated.getETag(); try { - client.createOrUpdateDataSourceWithResponse(original, true, null, Context.NONE); + client.createOrUpdateDataSourceConnectionWithResponse(original, true, null, Context.NONE); fail("createOrUpdateDefinition should have failed due to precondition."); } catch (HttpResponseException ex) { assertEquals(HttpURLConnection.HTTP_PRECON_FAILED, ex.getResponse().getStatusCode()); @@ -251,14 +250,14 @@ public void updateDataSourceIfNotChangedFailsWhenResourceChanged() { @Test public void updateDataSourceIfNotChangedSucceedsWhenResourceUnchanged() { - SearchIndexerDataSource dataSource = createTestBlobDataSource(null); + SearchIndexerDataSourceConnection dataSource = createTestBlobDataSource(null); dataSourcesToDelete.add(dataSource.getName()); - SearchIndexerDataSource original = client.createOrUpdateDataSourceWithResponse(dataSource, false, null, Context.NONE) + SearchIndexerDataSourceConnection original = client.createOrUpdateDataSourceConnectionWithResponse(dataSource, false, null, Context.NONE) .getValue(); String originalETag = original.getETag(); - SearchIndexerDataSource updated = client.createOrUpdateDataSourceWithResponse(original.setDescription("an update"), false, + SearchIndexerDataSourceConnection updated = client.createOrUpdateDataSourceConnectionWithResponse(original.setDescription("an update"), false, null, Context.NONE) .getValue(); String updatedETag = updated.getETag(); @@ -302,13 +301,13 @@ public void createDataSourceReturnsCorrectDefinition() { createAndValidateDataSource(createTestBlobDataSource(deletionDetectionPolicy)); } - private void createAndValidateDataSource(SearchIndexerDataSource expectedDataSource) { - SearchIndexerDataSource actualDataSource = client.createOrUpdateDataSource(expectedDataSource); + private void createAndValidateDataSource(SearchIndexerDataSourceConnection expectedDataSource) { + SearchIndexerDataSourceConnection actualDataSource = client.createOrUpdateDataSourceConnection(expectedDataSource); - expectedDataSource.setCredentials(new DataSourceCredentials().setConnectionString(null)); + expectedDataSource.setConnectionString(null); TestHelpers.assertObjectEquals(expectedDataSource, actualDataSource, false, "etag", "@odata.etag"); // we delete the data source because otherwise we will hit the quota limits during the tests - client.deleteDataSource(actualDataSource.getName()); + client.deleteDataSourceConnection(actualDataSource.getName()); } @@ -320,27 +319,27 @@ public void getDataSourceReturnsCorrectDefinition() { createGetAndValidateDataSource(createTestCosmosDataSource(null, false)); } - private void createGetAndValidateDataSource(SearchIndexerDataSource expectedDataSource) { - client.createOrUpdateDataSource(expectedDataSource); + private void createGetAndValidateDataSource(SearchIndexerDataSourceConnection expectedDataSource) { + client.createOrUpdateDataSourceConnection(expectedDataSource); String dataSourceName = expectedDataSource.getName(); // Get doesn't return connection strings. - expectedDataSource.setCredentials(new DataSourceCredentials().setConnectionString(null)); + expectedDataSource.setConnectionString(null); - SearchIndexerDataSource actualDataSource = client.getDataSource(dataSourceName); + SearchIndexerDataSourceConnection actualDataSource = client.getDataSourceConnection(dataSourceName); TestHelpers.assertObjectEquals(expectedDataSource, actualDataSource, false, "etag", "@odata.etag"); - actualDataSource = client.getDataSourceWithResponse(dataSourceName, generateRequestOptions(), Context.NONE) + actualDataSource = client.getDataSourceConnectionWithResponse(dataSourceName, generateRequestOptions(), Context.NONE) .getValue(); TestHelpers.assertObjectEquals(expectedDataSource, actualDataSource, false, "etag", "@odata.etag"); - client.deleteDataSource(dataSourceName); + client.deleteDataSourceConnection(dataSourceName); } @Test public void getDataSourceThrowsOnNotFound() { assertHttpResponseException( - () -> client.getDataSource("thisdatasourcedoesnotexist"), + () -> client.getDataSourceConnection("thisdatasourcedoesnotexist"), HttpURLConnection.HTTP_NOT_FOUND, "No data source with the name 'thisdatasourcedoesnotexist' was found in service" ); @@ -348,23 +347,23 @@ public void getDataSourceThrowsOnNotFound() { @Test public void canCreateDataSource() { - SearchIndexerDataSource expectedDataSource = createTestBlobDataSource(null); + SearchIndexerDataSourceConnection expectedDataSource = createTestBlobDataSource(null); dataSourcesToDelete.add(expectedDataSource.getName()); - SearchIndexerDataSource actualDataSource = client.createDataSource(expectedDataSource); + SearchIndexerDataSourceConnection actualDataSource = client.createDataSourceConnection(expectedDataSource); assertNotNull(actualDataSource); assertEquals(expectedDataSource.getName(), actualDataSource.getName()); - Iterator dataSources = client.listDataSources().iterator(); + Iterator dataSources = client.listDataSourceConnections().iterator(); assertEquals(expectedDataSource.getName(), dataSources.next().getName()); assertFalse(dataSources.hasNext()); } @Test public void canCreateDataSourceWithResponse() { - SearchIndexerDataSource expectedDataSource = createTestBlobDataSource(null); + SearchIndexerDataSourceConnection expectedDataSource = createTestBlobDataSource(null); dataSourcesToDelete.add(expectedDataSource.getName()); - Response response = client - .createDataSourceWithResponse(expectedDataSource, new RequestOptions(), null); + Response response = client + .createDataSourceConnectionWithResponse(expectedDataSource, new RequestOptions(), null); assertNotNull(response); assertNotNull(response.getValue()); assertEquals(expectedDataSource.getName(), response.getValue().getName()); @@ -378,28 +377,28 @@ public void canUpdateConnectionData() { // Hence, we only validate that the properties on the local items can change. // Create an initial dataSource - SearchIndexerDataSource initial = createTestBlobDataSource(null); - assertEquals(initial.getCredentials().getConnectionString(), FAKE_STORAGE_CONNECTION_STRING); + SearchIndexerDataSourceConnection initial = createTestBlobDataSource(null); + assertEquals(initial.getConnectionString(), FAKE_STORAGE_CONNECTION_STRING); // tweak the connection string and verify it was changed String newConnString = "DefaultEndpointsProtocol=https;AccountName=NotaRealYetDifferentAccount;AccountKey=AnotherFakeKey;"; - initial.setCredentials(new DataSourceCredentials().setConnectionString(newConnString)); + initial.setConnectionString(newConnString); - assertEquals(initial.getCredentials().getConnectionString(), newConnString); + assertEquals(initial.getConnectionString(), newConnString); } - SearchIndexerDataSource createTestBlobDataSource(DataDeletionDetectionPolicy deletionDetectionPolicy) { + SearchIndexerDataSourceConnection createTestBlobDataSource(DataDeletionDetectionPolicy deletionDetectionPolicy) { return SearchIndexerDataSources.createFromAzureBlobStorage(testResourceNamer.randomName(BLOB_DATASOURCE_TEST_NAME, 32), FAKE_STORAGE_CONNECTION_STRING, "fakecontainer", "/fakefolder/", FAKE_DESCRIPTION, deletionDetectionPolicy); } - SearchIndexerDataSource createTestTableStorageDataSource() { + SearchIndexerDataSourceConnection createTestTableStorageDataSource() { return SearchIndexerDataSources.createFromAzureTableStorage("azs-java-test-tablestorage", FAKE_STORAGE_CONNECTION_STRING, "faketable", "fake query", FAKE_DESCRIPTION, null); } - SearchIndexerDataSource createTestCosmosDataSource(DataDeletionDetectionPolicy deletionDetectionPolicy, + SearchIndexerDataSourceConnection createTestCosmosDataSource(DataDeletionDetectionPolicy deletionDetectionPolicy, boolean useChangeDetection) { return SearchIndexerDataSources.createFromCosmos("azs-java-test-cosmos", FAKE_COSMOS_CONNECTION_STRING, "faketable", @@ -407,7 +406,8 @@ SearchIndexerDataSource createTestCosmosDataSource(DataDeletionDetectionPolicy d deletionDetectionPolicy); } - private void assertDataSourceEquals(SearchIndexerDataSource expect, SearchIndexerDataSource actual) { + private void assertDataSourceEquals(SearchIndexerDataSourceConnection expect, + SearchIndexerDataSourceConnection actual) { assertEquals(expect.getName(), actual.getName()); assertEquals(expect.getDescription(), actual.getDescription()); assertEquals(expect.getType(), actual.getType()); diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/DataSourcesTest.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/DataSourcesTest.java index 5b8260e6d825..5ac4534501eb 100644 --- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/DataSourcesTest.java +++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/DataSourcesTest.java @@ -4,10 +4,9 @@ package com.azure.search.documents.indexes; import com.azure.search.documents.TestHelpers; -import com.azure.search.documents.indexes.models.DataSourceCredentials; import com.azure.search.documents.indexes.models.HighWaterMarkChangeDetectionPolicy; import com.azure.search.documents.indexes.models.SearchIndexerDataContainer; -import com.azure.search.documents.indexes.models.SearchIndexerDataSource; +import com.azure.search.documents.indexes.models.SearchIndexerDataSourceConnection; import com.azure.search.documents.indexes.models.SearchIndexerDataSourceType; import org.junit.jupiter.api.Test; @@ -19,13 +18,12 @@ public class DataSourcesTest { @Test public void canCreateSqlDataSource() { // check utility method with minimal overloads - SearchIndexerDataSource expected = new SearchIndexerDataSource() + SearchIndexerDataSourceConnection expected = new SearchIndexerDataSourceConnection() .setName("sql") .setType(SearchIndexerDataSourceType.AZURE_SQL) - .setCredentials(new DataSourceCredentials() - .setConnectionString("connectionString")) + .setConnectionString("connectionString") .setContainer(new SearchIndexerDataContainer().setName("table")); - SearchIndexerDataSource actual = SearchIndexerDataSources.createFromAzureSql( + SearchIndexerDataSourceConnection actual = SearchIndexerDataSources.createFromAzureSql( "sql", "connectionString", "table"); TestHelpers.assertObjectEquals(expected, actual, false, "etag"); @@ -34,14 +32,13 @@ public void canCreateSqlDataSource() { @Test public void canCreateStorageBlobDataSource() { // check utility method with minimal overloads - SearchIndexerDataSource expected = new SearchIndexerDataSource() + SearchIndexerDataSourceConnection expected = new SearchIndexerDataSourceConnection() .setName("storageBlob") .setType(SearchIndexerDataSourceType.AZURE_BLOB) - .setCredentials(new DataSourceCredentials() - .setConnectionString("connectionString")) + .setConnectionString("connectionString") .setContainer(new SearchIndexerDataContainer() .setName("container")); - SearchIndexerDataSource actual = SearchIndexerDataSources.createFromAzureBlobStorage( + SearchIndexerDataSourceConnection actual = SearchIndexerDataSources.createFromAzureBlobStorage( "storageBlob", "connectionString", "container"); TestHelpers.assertObjectEquals(expected, actual, false, "etag"); @@ -50,14 +47,13 @@ public void canCreateStorageBlobDataSource() { @Test public void canCreateStorageTableDataSource() { // check utility method with minimal overloads - SearchIndexerDataSource expected = new SearchIndexerDataSource() + SearchIndexerDataSourceConnection expected = new SearchIndexerDataSourceConnection() .setName("storageTable") .setType(SearchIndexerDataSourceType.AZURE_TABLE) - .setCredentials(new DataSourceCredentials() - .setConnectionString("connectionString")) + .setConnectionString("connectionString") .setContainer(new SearchIndexerDataContainer() .setName("table")); - SearchIndexerDataSource actual = SearchIndexerDataSources.createFromAzureTableStorage( + SearchIndexerDataSourceConnection actual = SearchIndexerDataSources.createFromAzureTableStorage( "storageTable", "connectionString", "table"); TestHelpers.assertObjectEquals(expected, actual, false, "etag"); @@ -66,15 +62,14 @@ public void canCreateStorageTableDataSource() { @Test public void canCreateCosmosDataSource() { // check utility method overloads - SearchIndexerDataSource expected = new SearchIndexerDataSource() + SearchIndexerDataSourceConnection expected = new SearchIndexerDataSourceConnection() .setName("cosmos") .setType(SearchIndexerDataSourceType.COSMOS_DB) - .setCredentials(new DataSourceCredentials() - .setConnectionString("connectionString")) + .setConnectionString("connectionString") .setContainer(new SearchIndexerDataContainer() .setName("collection")); - SearchIndexerDataSource actual = SearchIndexerDataSources.createFromCosmos("cosmos", "connectionString", "collection", false); + SearchIndexerDataSourceConnection actual = SearchIndexerDataSources.createFromCosmos("cosmos", "connectionString", "collection", false); TestHelpers.assertObjectEquals(expected, actual, false, "etag"); } @@ -82,16 +77,15 @@ public void canCreateCosmosDataSource() { @Test public void canCreateCosmosDataSourceWithMinimalOverload() { // check utility method with minimal overloads - SearchIndexerDataSource expected = new SearchIndexerDataSource() + SearchIndexerDataSourceConnection expected = new SearchIndexerDataSourceConnection() .setName("cosmos") .setType(SearchIndexerDataSourceType.COSMOS_DB) - .setCredentials(new DataSourceCredentials() - .setConnectionString("connectionString")) + .setConnectionString("connectionString") .setContainer(new SearchIndexerDataContainer() .setName("collection")) .setDataChangeDetectionPolicy(new HighWaterMarkChangeDetectionPolicy().setHighWaterMarkColumnName("_ts")); - SearchIndexerDataSource actual = SearchIndexerDataSources.createFromCosmos("cosmos", + SearchIndexerDataSourceConnection actual = SearchIndexerDataSources.createFromCosmos("cosmos", "connectionString", "collection"); TestHelpers.assertObjectEquals(expected, actual, false, "etag"); diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/IndexersManagementSyncTests.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/IndexersManagementSyncTests.java index 47ff2facd6c6..84d483631551 100644 --- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/IndexersManagementSyncTests.java +++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/IndexersManagementSyncTests.java @@ -21,7 +21,7 @@ import com.azure.search.documents.indexes.models.SearchFieldDataType; import com.azure.search.documents.indexes.models.SearchIndex; import com.azure.search.documents.indexes.models.SearchIndexer; -import com.azure.search.documents.indexes.models.SearchIndexerDataSource; +import com.azure.search.documents.indexes.models.SearchIndexerDataSourceConnection; import com.azure.search.documents.indexes.models.SearchIndexerLimits; import com.azure.search.documents.indexes.models.SearchIndexerSkill; import com.azure.search.documents.indexes.models.SearchIndexerSkillset; @@ -65,8 +65,9 @@ public class IndexersManagementSyncTests extends SearchTestBase { private SearchIndexClient searchIndexClient; private String createDataSource() { - SearchIndexerDataSource dataSource = createTestSqlDataSourceObject(); - searchIndexerClient.createOrUpdateDataSource(dataSource); + SearchIndexerDataSourceConnection dataSource = createTestSqlDataSourceObject(); + searchIndexerClient.createOrUpdateDataSourceConnection(dataSource); + dataSourcesToDelete.add(dataSource.getName()); return dataSource.getName(); @@ -120,7 +121,7 @@ protected void afterTest() { } for (String dataSource : dataSourcesToDelete) { - searchIndexerClient.deleteDataSource(dataSource); + searchIndexerClient.deleteDataSourceConnection(dataSource); } for (String indexer : indexersToDelete) { @@ -389,7 +390,7 @@ public void canCreateIndexerWithBatchSizeMaxFailedItems() { @Test public void canUpdateIndexerBlobParams() { String indexName = createIndex(); - String dataSourceName = searchIndexerClient.createDataSource(createBlobDataSource()).getName(); + String dataSourceName = searchIndexerClient.createDataSourceConnection(createBlobDataSource()).getName(); dataSourcesToDelete.add(dataSourceName); SearchIndexer initial = createBaseTestIndexerObject(indexName, dataSourceName).setIsDisabled(true); @@ -409,10 +410,11 @@ public void canUpdateIndexerBlobParams() { @Test public void canCreateIndexerWithBlobParams() { // Create the needed Azure blob resources and data source object - SearchIndexerDataSource blobDataSource = createBlobDataSource(); + SearchIndexerDataSourceConnection blobDataSource = createBlobDataSource(); // Create the data source within the search service - SearchIndexerDataSource dataSource = searchIndexerClient.createOrUpdateDataSource(blobDataSource); + SearchIndexerDataSourceConnection dataSource = searchIndexerClient.createOrUpdateDataSourceConnection(blobDataSource); + dataSourcesToDelete.add(dataSource.getName()); // modify the indexer's blob params diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/SynonymMapManagementSyncTests.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/SynonymMapManagementSyncTests.java index b3d29f60efc1..83328cf87f36 100644 --- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/SynonymMapManagementSyncTests.java +++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/SynonymMapManagementSyncTests.java @@ -298,8 +298,15 @@ public void canCreateAndListSynonymMaps() { Iterator actual = client.listSynonymMaps().iterator(); - assertObjectEquals(synonymMap1, actual.next(), true); - assertObjectEquals(synonymMap2, actual.next(), true); + SynonymMap temp = actual.next(); + if (synonymMap1.getName().equals(temp.getName())) { + assertObjectEquals(synonymMap1, temp, true); + assertObjectEquals(synonymMap2, actual.next(), true); + } else { + assertObjectEquals(synonymMap2, temp, true); + assertObjectEquals(synonymMap1, actual.next(), true); + } + assertFalse(actual.hasNext()); }