diff --git a/sdk/search/azure-search-documents/CHANGELOG.md b/sdk/search/azure-search-documents/CHANGELOG.md index 37596461dd3d..b1fe02b7b407 100644 --- a/sdk/search/azure-search-documents/CHANGELOG.md +++ b/sdk/search/azure-search-documents/CHANGELOG.md @@ -8,6 +8,8 @@ - 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 `select` parameter from list service resource APIs. +- Added list names APIs for each search service resource. (e.g. `listSearchIndexNames`, `listSearchIndexerNames`, `listDataSourceNames`, `listSkillsetNames`, `listSynonymMapNames`) ## 1.0.0-beta.3 (2020-05-05) - Replaced `isRetrievable` API with `isHidden`, parameter name changed from `retrievable` to `hidden`. 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 9a7733f3dfc2..7ff150d75290 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 @@ -61,6 +61,15 @@ public static PagedResponse mappingPagingDataSource( dataSourceMaps, null, null); } + public static PagedResponse mappingPagingDataSourceNames( + Response dataSourceResponse) { + List dataSourceNames = dataSourceResponse.getValue().getDataSources().stream() + .map(SearchIndexerDataSourceConverter::map).map(SearchIndexerDataSource::getName).collect(toList()); + return new PagedResponseBase( + dataSourceResponse.getRequest(), dataSourceResponse.getStatusCode(), dataSourceResponse.getHeaders(), + dataSourceNames, null, null); + } + public static PagedResponse mappingPagingSearchIndex( Response searchIndexResponse) { List searchIndices = searchIndexResponse.getValue().getIndexes().stream() @@ -70,6 +79,15 @@ public static PagedResponse mappingPagingSearchIndex( searchIndices, null, null); } + public static PagedResponse mappingPagingSearchIndexNames(Response + searchIndexResponse) { + List searchIndexNames = searchIndexResponse.getValue().getIndexes().stream() + .map(SearchIndexConverter::map).map(SearchIndex::getName).collect(toList()); + return new PagedResponseBase( + searchIndexResponse.getRequest(), searchIndexResponse.getStatusCode(), searchIndexResponse.getHeaders(), + searchIndexNames, null, null); + } + public static Response mappingExternalSearchIndex( Response indexResponse) { return new SimpleResponse<>(indexResponse, SearchIndexConverter.map(indexResponse.getValue())); @@ -84,6 +102,15 @@ public static PagedResponse mappingPagingSearchIndexer( searchIndexerResponse.getHeaders(), searchIndexers, null, null); } + public static PagedResponse mappingPagingSearchIndexerNames( + Response searchIndexerResponse) { + List searchIndexerNames = searchIndexerResponse.getValue().getIndexers().stream() + .map(SearchIndexerConverter::map).map(SearchIndexer::getName).collect(toList()); + return new PagedResponseBase( + searchIndexerResponse.getRequest(), searchIndexerResponse.getStatusCode(), + searchIndexerResponse.getHeaders(), searchIndexerNames, null, null); + } + public static Response mappingExternalSearchIndexer( Response indexerResponse) { return new SimpleResponse<>(indexerResponse, SearchIndexerConverter.map(indexerResponse.getValue())); @@ -97,11 +124,20 @@ public static Response mappingExternalSkillset( public static PagedResponse mappingPagingSkillset( Response skillsetResponse) { - List synonymMaps = skillsetResponse.getValue().getSkillsets().stream() + List skillsets = skillsetResponse.getValue().getSkillsets().stream() .map(SearchIndexerSkillsetConverter::map).collect(toList()); return new PagedResponseBase( skillsetResponse.getRequest(), skillsetResponse.getStatusCode(), skillsetResponse.getHeaders(), - synonymMaps, null, null); + skillsets, null, null); + } + + public static PagedResponse mappingPagingSkillsetNames( + Response skillsetResponse) { + List skillsetNames = skillsetResponse.getValue().getSkillsets().stream() + .map(SearchIndexerSkillsetConverter::map).map(SearchIndexerSkillset::getName).collect(toList()); + return new PagedResponseBase( + skillsetResponse.getRequest(), skillsetResponse.getStatusCode(), skillsetResponse.getHeaders(), + skillsetNames, null, null); } public static Response mappingExternalSynonymMap( @@ -118,6 +154,15 @@ public static PagedResponse mappingPagingSynonymMap( synonymMaps, null, null); } + public static PagedResponse mappingPagingSynonymMapNames( + Response synonymMapsResponse) { + List synonymMapNames = synonymMapsResponse.getValue().getSynonymMaps().stream() + .map(SynonymMapConverter::map).map(SynonymMap::getName).collect(toList()); + return new PagedResponseBase( + synonymMapsResponse.getRequest(), synonymMapsResponse.getStatusCode(), synonymMapsResponse.getHeaders(), + synonymMapNames, null, null); + } + public static Response mappingExternalServiceStatistics( Response statisticsResponse) { return new SimpleResponse<>(statisticsResponse, diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexAsyncClient.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexAsyncClient.java index 42f6cc72baf1..7cc0073675c2 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexAsyncClient.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexAsyncClient.java @@ -7,6 +7,7 @@ import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; import com.azure.core.util.logging.ClientLogger; @@ -20,6 +21,8 @@ import com.azure.search.documents.implementation.util.MappingUtils; import com.azure.search.documents.indexes.implementation.SearchServiceRestClientBuilder; import com.azure.search.documents.indexes.implementation.SearchServiceRestClientImpl; +import com.azure.search.documents.indexes.implementation.models.ListIndexesResult; +import com.azure.search.documents.indexes.implementation.models.ListSynonymMapsResult; import com.azure.search.documents.indexes.models.AnalyzeRequest; import com.azure.search.documents.indexes.models.AnalyzedTokenInfo; import com.azure.search.documents.indexes.models.GetIndexStatisticsResult; @@ -242,35 +245,61 @@ public PagedFlux listIndexes() { /** * Lists all indexes available for an Azure Cognitive Search service. * - * @param select selects which top-level properties of the index definitions to retrieve. Specified as a - * comma-separated list of JSON property names, or '*' for all properties. The default is all properties * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to * help with debugging * @return a reactive response emitting the list of indexes. */ - public PagedFlux listIndexes(String select, RequestOptions requestOptions) { + public PagedFlux listIndexes(RequestOptions requestOptions) { try { return new PagedFlux<>(() -> - withContext(context -> this.listIndexesWithResponse(select, requestOptions, context))); + withContext(context -> this.listIndexesWithResponse(null, requestOptions, context)) + .map(MappingUtils::mappingPagingSearchIndex)); } catch (RuntimeException ex) { return pagedFluxError(logger, ex); } } - PagedFlux listIndexes(String select, RequestOptions requestOptions, Context context) { + PagedFlux listIndexes(RequestOptions requestOptions, Context context) { try { - return new PagedFlux<>(() -> this.listIndexesWithResponse(select, requestOptions, context)); + return new PagedFlux<>(() -> this.listIndexesWithResponse(null, requestOptions, context) + .map(MappingUtils::mappingPagingSearchIndex)); } catch (RuntimeException ex) { return pagedFluxError(logger, ex); } } - private Mono> listIndexesWithResponse(String select, RequestOptions requestOptions, - Context context) { + /** + * Lists all indexes names for an Azure Cognitive Search service. + * + * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to + * help with debugging + * @return a reactive response emitting the list of index names. + */ + public PagedFlux listIndexNames(RequestOptions requestOptions) { + try { + return new PagedFlux<>(() -> + withContext(context -> this.listIndexesWithResponse("name", requestOptions, context)) + .map(MappingUtils::mappingPagingSearchIndexNames)); + } catch (RuntimeException ex) { + return pagedFluxError(logger, ex); + } + } + + PagedFlux listIndexNames(RequestOptions requestOptions, Context context) { + try { + return new PagedFlux<>(() -> this.listIndexesWithResponse("name", requestOptions, context) + .map(MappingUtils::mappingPagingSearchIndexNames) + ); + } catch (RuntimeException ex) { + return pagedFluxError(logger, ex); + } + } + + private Mono> listIndexesWithResponse(String select, + RequestOptions requestOptions, Context context) { return restClient.indexes() .listWithRestResponseAsync(select, RequestOptionsIndexesConverter.map(requestOptions), context) - .onErrorMap(MappingUtils::exceptionMapper) - .map(MappingUtils::mappingPagingSearchIndex); + .onErrorMap(MappingUtils::exceptionMapper); } /** @@ -484,41 +513,66 @@ Mono> getSynonymMapWithResponse(String synonymMapName, Requ * @return a reactive response emitting the list of synonym maps. */ public PagedFlux listSynonymMaps() { - return listSynonymMaps(null, null); + return listSynonymMaps(null); } /** * Lists all synonym maps available for an Azure Cognitive Search service. * - * @param select selects which top-level properties of the synonym maps to retrieve. Specified as a comma-separated - * list of JSON property names, or '*' for all properties. The default is all properties * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to * help with debugging * @return a reactive response emitting the list of synonym maps. */ - public PagedFlux listSynonymMaps(String select, RequestOptions requestOptions) { + public PagedFlux listSynonymMaps(RequestOptions requestOptions) { try { return new PagedFlux<>(() -> - withContext(context -> listSynonymMapsWithResponse(select, requestOptions, context))); + withContext(context -> listSynonymMapsWithResponse(null, requestOptions, context)) + .map(MappingUtils::mappingPagingSynonymMap)); } catch (RuntimeException ex) { return pagedFluxError(logger, ex); } } - PagedFlux listSynonymMaps(String select, RequestOptions requestOptions, Context context) { + PagedFlux listSynonymMaps(RequestOptions requestOptions, Context context) { try { - return new PagedFlux<>(() -> listSynonymMapsWithResponse(select, requestOptions, context)); + return new PagedFlux<>(() -> listSynonymMapsWithResponse(null, requestOptions, context) + .map(MappingUtils::mappingPagingSynonymMap)); } catch (RuntimeException ex) { return pagedFluxError(logger, ex); } } - private Mono> listSynonymMapsWithResponse(String select, RequestOptions requestOptions, - Context context) { + /** + * Lists all synonym map names for an Azure Cognitive Search service. + * + * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to + * help with debugging + * @return a reactive response emitting the list of synonym map names. + */ + public PagedFlux listSynonymMapNames(RequestOptions requestOptions) { + try { + return new PagedFlux<>(() -> + withContext(context -> listSynonymMapsWithResponse("name", requestOptions, context)) + .map(MappingUtils::mappingPagingSynonymMapNames)); + } catch (RuntimeException ex) { + return pagedFluxError(logger, ex); + } + } + + PagedFlux listSynonymMapNames(RequestOptions requestOptions, Context context) { + try { + return new PagedFlux<>(() -> listSynonymMapsWithResponse("name", requestOptions, context) + .map(MappingUtils::mappingPagingSynonymMapNames)); + } catch (RuntimeException ex) { + return pagedFluxError(logger, ex); + } + } + + private Mono> listSynonymMapsWithResponse(String select, + RequestOptions requestOptions, Context context) { return restClient.synonymMaps() .listWithRestResponseAsync(select, RequestOptionsIndexesConverter.map(requestOptions), context) - .onErrorMap(MappingUtils::exceptionMapper) - .map(MappingUtils::mappingPagingSynonymMap); + .onErrorMap(MappingUtils::exceptionMapper); } /** diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexClient.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexClient.java index f14aa32a3ba9..8c389613ded7 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexClient.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexClient.java @@ -144,21 +144,40 @@ public Response getIndexStatisticsWithResponse(String * @return the list of indexes. */ public PagedIterable listIndexes() { - return listIndexes(null, null, Context.NONE); + return listIndexes(null, Context.NONE); } /** * Lists all indexes available for an Azure Cognitive Search service. * - * @param select selects which top-level properties of the index definitions to retrieve. Specified as a - * comma-separated list of JSON property names, or '*' for all properties. The default is all properties * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to * help with debugging * @param context additional context that is passed through the HTTP pipeline during the service call * @return the list of indexes. */ - public PagedIterable listIndexes(String select, RequestOptions requestOptions, Context context) { - return new PagedIterable<>(asyncClient.listIndexes(select, requestOptions, context)); + public PagedIterable listIndexes(RequestOptions requestOptions, Context context) { + return new PagedIterable<>(asyncClient.listIndexes(requestOptions, context)); + } + + /** + * Lists all index names for an Azure Cognitive Search service. + * + * @return the list of index names. + */ + public PagedIterable listIndexNames() { + return listIndexNames(null, Context.NONE); + } + + /** + * Lists all indexes names for an Azure Cognitive Search service. + * + * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to + * help with debugging + * @param context additional context that is passed through the HTTP pipeline during the service call + * @return the list of index names. + */ + public PagedIterable listIndexNames(RequestOptions requestOptions, Context context) { + return new PagedIterable<>(asyncClient.listIndexNames(requestOptions, context)); } /** @@ -298,21 +317,40 @@ public Response getSynonymMapWithResponse(String synonymMapName, Req * @return the list of synonym maps. */ public PagedIterable listSynonymMaps() { - return listSynonymMaps(null, null, Context.NONE); + return listSynonymMaps(null, Context.NONE); } /** * Lists all synonym maps available for an Azure Cognitive Search service. * - * @param select selects which top-level properties of the index definitions to retrieve. Specified as a - * comma-separated list of JSON property names, or '*' for all properties. The default is all properties * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to * help with debugging * @param context additional context that is passed through the HTTP pipeline during the service call + * @return the list of synonym map names. + */ + public PagedIterable listSynonymMaps(RequestOptions requestOptions, Context context) { + return new PagedIterable<>(asyncClient.listSynonymMaps(requestOptions, context)); + } + + /** + * Lists all synonym maps names for an Azure Cognitive Search service. + * * @return the list of synonym maps. */ - public PagedIterable listSynonymMaps(String select, RequestOptions requestOptions, Context context) { - return new PagedIterable<>(asyncClient.listSynonymMaps(select, requestOptions, context)); + public PagedIterable listSynonymMapNames() { + return listSynonymMapNames(null, Context.NONE); + } + + /** + * Lists all synonym maps names for an Azure Cognitive Search service. + * + * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to + * help with debugging + * @param context additional context that is passed through the HTTP pipeline during the service call + * @return the list of synonym map names. + */ + public PagedIterable listSynonymMapNames(RequestOptions requestOptions, Context context) { + return new PagedIterable<>(asyncClient.listSynonymMapNames(requestOptions, context)); } /** diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexClientBuilder.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexClientBuilder.java index ef96a55ec42b..c660da6af9bc 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexClientBuilder.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexClientBuilder.java @@ -109,6 +109,7 @@ public SearchIndexClient buildClient() { */ public SearchIndexAsyncClient buildAsyncClient() { Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(keyCredential, "'keyCredential' cannot be null."); SearchServiceVersion buildVersion = (serviceVersion == null) ? SearchServiceVersion.getLatest() 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 e64e17e5f7a8..8adba2f2d746 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 @@ -5,8 +5,8 @@ import com.azure.core.http.HttpPipeline; import com.azure.core.http.rest.PagedFlux; -import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; import com.azure.core.util.logging.ClientLogger; @@ -18,6 +18,9 @@ import com.azure.search.documents.implementation.util.MappingUtils; import com.azure.search.documents.indexes.implementation.SearchServiceRestClientBuilder; import com.azure.search.documents.indexes.implementation.SearchServiceRestClientImpl; +import com.azure.search.documents.indexes.implementation.models.ListDataSourcesResult; +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.SearchIndexerSkillset; @@ -226,35 +229,69 @@ public PagedFlux listDataSources() { /** * List all DataSources from an Azure Cognitive Search service. * - * @param select Selects which top-level properties of DataSource definitions to retrieve. Specified as a - * comma-separated list of JSON property names, or '*' for all properties. The default is all properties. * @param requestOptions Additional parameters for the operation. Contains the tracking ID sent with the request to * help with debugging. * @return a list of DataSources */ - public PagedFlux listDataSources(String select, RequestOptions requestOptions) { + public PagedFlux listDataSources(RequestOptions requestOptions) { try { return new PagedFlux<>(() -> - withContext(context -> this.listDataSourcesWithResponse(select, requestOptions, context))); + withContext(context -> this.listDataSourcesWithResponse(null, requestOptions, context)) + .map(MappingUtils::mappingPagingDataSource)); } catch (RuntimeException ex) { return pagedFluxError(logger, ex); } } - PagedFlux listDataSources(String select, RequestOptions requestOptions, Context context) { + PagedFlux listDataSources(RequestOptions requestOptions, Context context) { try { - return new PagedFlux<>(() -> this.listDataSourcesWithResponse(select, requestOptions, context)); + return new PagedFlux<>(() -> this.listDataSourcesWithResponse(null, requestOptions, context) + .map(MappingUtils::mappingPagingDataSource)); } catch (RuntimeException ex) { return pagedFluxError(logger, ex); } } - private Mono> listDataSourcesWithResponse(String select, + /** + * List all DataSource names from an Azure Cognitive Search service. + * + * @return a list of DataSource names + */ + public PagedFlux listDataSourceNames() { + return listDataSources(null, null); + } + + /** + * List all DataSource names from an Azure Cognitive Search service. + * + * @param requestOptions Additional parameters for the operation. Contains the tracking ID sent with the request to + * help with debugging. + * @return a list of DataSource names + */ + public PagedFlux listDataSourceNames(RequestOptions requestOptions) { + try { + return new PagedFlux<>(() -> + withContext(context -> this.listDataSourcesWithResponse("name", requestOptions, context)) + .map(MappingUtils::mappingPagingDataSourceNames)); + } catch (RuntimeException ex) { + return pagedFluxError(logger, ex); + } + } + + PagedFlux listDataSourceNames(RequestOptions requestOptions, Context context) { + try { + return new PagedFlux<>(() -> this.listDataSourcesWithResponse("name", requestOptions, context) + .map(MappingUtils::mappingPagingDataSourceNames)); + } catch (RuntimeException ex) { + return pagedFluxError(logger, ex); + } + } + + private Mono> listDataSourcesWithResponse(String select, RequestOptions requestOptions, Context context) { return restClient.dataSources() .listWithRestResponseAsync(select, RequestOptionsIndexesConverter.map(requestOptions), context) - .onErrorMap(MappingUtils::exceptionMapper) - .map(MappingUtils::mappingPagingDataSource); + .onErrorMap(MappingUtils::exceptionMapper); } /** @@ -416,43 +453,78 @@ Mono> getIndexerWithResponse(String indexerName, Request } /** + * Lists all indexers available for an Azure Cognitive Search service. + * * @return all Indexers from the Search service. */ public PagedFlux listIndexers() { - return listIndexers(null, null); + return listIndexers(null); } /** * Lists all indexers available for an Azure Cognitive Search service. * - * @param select Selects which top-level properties of the indexers to retrieve. Specified as a comma-separated list - * of JSON property names, or '*' for all properties. The default is all properties. * @param requestOptions Additional parameters for the operation. * @return a response containing all Indexers from the Search service. */ - public PagedFlux listIndexers(String select, RequestOptions requestOptions) { + public PagedFlux listIndexers(RequestOptions requestOptions) { try { return new PagedFlux<>(() -> - withContext(context -> this.listIndexersWithResponse(select, requestOptions, context))); + withContext(context -> this.listIndexersWithResponse(null, requestOptions, context)) + .map(MappingUtils::mappingPagingSearchIndexer)); } catch (RuntimeException ex) { return pagedFluxError(logger, ex); } } - PagedFlux listIndexers(String select, RequestOptions requestOptions, Context context) { + PagedFlux listIndexers(RequestOptions requestOptions, Context context) { try { - return new PagedFlux<>(() -> this.listIndexersWithResponse(select, requestOptions, context)); + return new PagedFlux<>(() -> this.listIndexersWithResponse(null, requestOptions, context) + .map(MappingUtils::mappingPagingSearchIndexer)); } catch (RuntimeException ex) { return pagedFluxError(logger, ex); } } - private Mono> listIndexersWithResponse(String select, RequestOptions requestOptions, - Context context) { + /** + * Lists all indexers names for an Azure Cognitive Search service. + * + * @return all Indexer names from the Search service. + */ + public PagedFlux listIndexerNames() { + return listIndexerNames(null, null); + } + + /** + * Lists all indexers available for an Azure Cognitive Search service. + * + * @param requestOptions Additional parameters for the operation. + * @return a response containing all Indexers from the Search service. + */ + public PagedFlux listIndexerNames(RequestOptions requestOptions) { + try { + return new PagedFlux<>(() -> + withContext(context -> this.listIndexersWithResponse("name", requestOptions, context)) + .map(MappingUtils::mappingPagingSearchIndexerNames)); + } catch (RuntimeException ex) { + return pagedFluxError(logger, ex); + } + } + + PagedFlux listIndexerNames(RequestOptions requestOptions, Context context) { + try { + return new PagedFlux<>(() -> this.listIndexersWithResponse("name", requestOptions, context) + .map(MappingUtils::mappingPagingSearchIndexerNames)); + } catch (RuntimeException ex) { + return pagedFluxError(logger, ex); + } + } + + private Mono> listIndexersWithResponse(String select, + RequestOptions requestOptions, Context context) { return restClient.indexers() .listWithRestResponseAsync(select, RequestOptionsIndexesConverter.map(requestOptions), context) - .onErrorMap(MappingUtils::exceptionMapper) - .map(MappingUtils::mappingPagingSearchIndexer); + .onErrorMap(MappingUtils::exceptionMapper); } /** @@ -692,36 +764,70 @@ public PagedFlux listSkillsets() { /** * Lists all skillsets available for an Azure Cognitive Search service. * - * @param select selects which top-level properties of the skillset definitions to retrieve. Specified as a - * comma-separated list of JSON property names, or '*' for all properties. The default is all properties * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to * help with debugging * @return a reactive response emitting the list of skillsets. */ - public PagedFlux listSkillsets(String select, RequestOptions requestOptions) { + public PagedFlux listSkillsets(RequestOptions requestOptions) { + try { + return new PagedFlux<>(() -> + withContext(context -> listSkillsetsWithResponse(null, requestOptions, context)) + .map(MappingUtils::mappingPagingSkillset)); + } catch (RuntimeException ex) { + return pagedFluxError(logger, ex); + } + } + + PagedFlux listSkillsets(RequestOptions requestOptions, Context context) { + try { + return new PagedFlux<>(() -> listSkillsetsWithResponse(null, requestOptions, context) + .map(MappingUtils::mappingPagingSkillset)); + } catch (RuntimeException ex) { + return pagedFluxError(logger, ex); + } + } + + /** + * Lists all skillsets names for an Azure Cognitive Search service. + * + * @return a reactive response emitting the list of skillset names. + */ + public PagedFlux listSkillsetNames() { + return listSkillsetNames(null, null); + } + + /** + * Lists all skillset names for an Azure Cognitive Search service. + * + * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to + * help with debugging + * @return a reactive response emitting the list of skillset names. + */ + public PagedFlux listSkillsetNames(RequestOptions requestOptions) { try { return new PagedFlux<>(() -> - withContext(context -> listSkillsetsWithResponse(select, requestOptions, context))); + withContext(context -> listSkillsetsWithResponse("name", requestOptions, context)) + .map(MappingUtils::mappingPagingSkillsetNames)); } catch (RuntimeException ex) { return pagedFluxError(logger, ex); } } - PagedFlux listSkillsets(String select, RequestOptions requestOptions, Context context) { + PagedFlux listSkillsetNames(RequestOptions requestOptions, Context context) { try { - return new PagedFlux<>(() -> listSkillsetsWithResponse(select, requestOptions, context)); + return new PagedFlux<>(() -> listSkillsetsWithResponse("name", requestOptions, context) + .map(MappingUtils::mappingPagingSkillsetNames)); } catch (RuntimeException ex) { return pagedFluxError(logger, ex); } } - private Mono> listSkillsetsWithResponse(String select, + private Mono> listSkillsetsWithResponse(String select, RequestOptions requestOptions, Context context) { return this.restClient.skillsets() .listWithRestResponseAsync(select, RequestOptionsIndexesConverter.map(requestOptions), context) - .onErrorMap(MappingUtils::exceptionMapper) - .map(MappingUtils::mappingPagingSkillset); + .onErrorMap(MappingUtils::exceptionMapper); } /** 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 a01487064407..2eadea7fca4b 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 @@ -132,22 +132,41 @@ public Response getDataSourceWithResponse(String dataSo * @return a list of DataSources */ public PagedIterable listDataSources() { - return listDataSources(null, null, Context.NONE); + return listDataSources(null, Context.NONE); } /** * List all DataSources from an Azure Cognitive Search service. * - * @param select Selects which top-level properties of DataSource definitions to retrieve. Specified as a - * comma-separated list of JSON property names, or '*' for all properties. The default is all properties. * @param requestOptions Additional parameters for the operation. Contains the tracking ID sent with the request to * help with debugging. * @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(String select, RequestOptions requestOptions, + public PagedIterable listDataSources(RequestOptions requestOptions, Context context) { - return new PagedIterable<>(asyncClient.listDataSources(select, requestOptions, context)); + return new PagedIterable<>(asyncClient.listDataSources(requestOptions, context)); + } + + /** + * List all DataSources names from an Azure Cognitive Search service. + *. + * @param requestOptions Additional parameters for the operation. Contains the tracking ID sent with the request to + * help with debugging. + * @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)); + } + + /** + * List all DataSource names from an Azure Cognitive Search service. + * + * @return a list of DataSources names + */ + public PagedIterable listDataSourceNames() { + return listDataSourceNames(null, Context.NONE); } /** @@ -232,20 +251,38 @@ public Response createOrUpdateIndexerWithResponse(SearchIndexer i * @return all Indexers from the Search service. */ public PagedIterable listIndexers() { - return listIndexers(null, null, Context.NONE); + return listIndexers(null, Context.NONE); } /** * Lists all indexers available for an Azure Cognitive Search service. * - * @param select Selects which top-level properties of the indexers to retrieve. Specified as a comma-separated list - * of JSON property names, or '*' for all properties. The default is all properties. * @param requestOptions Additional parameters for the operation. * @param context additional context that is passed through the HTTP pipeline during the service call * @return all Indexers from the Search service. */ - public PagedIterable listIndexers(String select, RequestOptions requestOptions, Context context) { - return new PagedIterable<>(asyncClient.listIndexers(select, requestOptions, context)); + public PagedIterable listIndexers(RequestOptions requestOptions, Context context) { + return new PagedIterable<>(asyncClient.listIndexers(requestOptions, context)); + } + + /** + * Lists all indexers names for an Azure Cognitive Search service. + * + * @return all Indexer names from the Search service . + */ + public PagedIterable listIndexerNames() { + return listIndexerNames(null, Context.NONE); + } + + /** + * Lists all indexers names for an Azure Cognitive Search service. + * + * @param requestOptions Additional parameters for the operation. + * @param context additional context that is passed through the HTTP pipeline during the service call + * @return all Indexer names from the Search service. + */ + public PagedIterable listIndexerNames(RequestOptions requestOptions, Context context) { + return new PagedIterable<>(asyncClient.listIndexerNames(requestOptions, context)); } /** @@ -422,22 +459,41 @@ public Response getSkillsetWithResponse(String skillsetNa * @return the list of skillsets. */ public PagedIterable listSkillsets() { - return listSkillsets(null, null, Context.NONE); + return listSkillsets(null, Context.NONE); } /** * Lists all skillsets available for an Azure Cognitive Search service. * - * @param select selects which top-level properties of the skillset definitions to retrieve. Specified as a - * comma-separated list of JSON property names, or '*' for all properties. The default is all properties * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to * help with debugging * @param context additional context that is passed through the HTTP pipeline during the service call * @return the list of skillsets. */ - public PagedIterable listSkillsets(String select, RequestOptions requestOptions, + public PagedIterable listSkillsets(RequestOptions requestOptions, Context context) { - return new PagedIterable<>(asyncClient.listSkillsets(select, requestOptions, context)); + return new PagedIterable<>(asyncClient.listSkillsets(requestOptions, context)); + } + + /** + * Lists all skillset names for an Azure Cognitive Search service. + * + * @return the list of skillset names. + */ + public PagedIterable listSkillsetNames() { + return listSkillsetNames(null, Context.NONE); + } + + /** + * Lists all skillset names for an Azure Cognitive Search service. + * + * @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to + * help with debugging + * @param context additional context that is passed through the HTTP pipeline during the service call + * @return the list of skillset names. + */ + public PagedIterable listSkillsetNames(RequestOptions requestOptions, Context context) { + return new PagedIterable<>(asyncClient.listSkillsetNames(requestOptions, context)); } /** diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerClientBuilder.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerClientBuilder.java index 274fdd0a91b8..af360ae86247 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerClientBuilder.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/SearchIndexerClientBuilder.java @@ -110,6 +110,7 @@ public SearchIndexerClient buildClient() { */ public SearchIndexerAsyncClient buildAsyncClient() { Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(keyCredential, "'keyCredential' cannot be null."); SearchServiceVersion buildVersion = (serviceVersion == null) ? SearchServiceVersion.getLatest() diff --git a/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/ListIndexersExample.java b/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/ListIndexersExample.java index 6553f3b2f7f9..282fc115b6f5 100644 --- a/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/ListIndexersExample.java +++ b/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/ListIndexersExample.java @@ -35,8 +35,8 @@ public static void main(String[] args) { } private static void listIndexers(SearchIndexerAsyncClient indexerAsyncClient) { - PagedResponse response = indexerAsyncClient.listIndexers("*", - new RequestOptions()).byPage().blockFirst(); + PagedResponse response = indexerAsyncClient.listIndexers(new RequestOptions(), null) + .byPage().blockFirst(); if (response != null) { System.out.println(String.format("Response code: %s", response.getStatusCode())); 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 c68c4e9931e2..e9defa880e16 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 @@ -72,8 +72,8 @@ public void canCreateAndListDataSources() { Iterator results = client.listDataSources().iterator(); - assertEquals(dataSource1.getName(), results.next().getName()); - assertEquals(dataSource2.getName(), results.next().getName()); + assertDataSourceEquals(dataSource1, results.next()); + assertDataSourceEquals(dataSource2, results.next()); assertFalse(results.hasNext()); } @@ -87,10 +87,9 @@ public void canCreateAndListDataSourcesWithResponse() { client.createOrUpdateDataSourceWithResponse(dataSource2, false, new RequestOptions(), Context.NONE); dataSourcesToDelete.add(dataSource2.getName()); - Iterator results = client.listDataSources("name", new RequestOptions(), Context.NONE).iterator(); - - assertEquals(dataSource1.getName(), results.next().getName()); - assertEquals(dataSource2.getName(), results.next().getName()); + Iterator results = client.listDataSourceNames(new RequestOptions(), Context.NONE).iterator(); + assertEquals(dataSource1.getName(), results.next()); + assertEquals(dataSource2.getName(), results.next()); assertFalse(results.hasNext()); } @@ -407,4 +406,11 @@ SearchIndexerDataSource createTestCosmosDataSource(DataDeletionDetectionPolicy d "SELECT ... FROM x where x._ts > @HighWaterMark", useChangeDetection, FAKE_DESCRIPTION, deletionDetectionPolicy); } + + private void assertDataSourceEquals(SearchIndexerDataSource expect, SearchIndexerDataSource actual) { + assertEquals(expect.getName(), actual.getName()); + assertEquals(expect.getDescription(), actual.getDescription()); + assertEquals(expect.getType(), actual.getType()); + assertEquals(expect.getContainer().getName(), actual.getContainer().getName()); + } } diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/IndexManagementSyncTests.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/IndexManagementSyncTests.java index 2fddb9d38186..91e7cb7b12d7 100644 --- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/IndexManagementSyncTests.java +++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/IndexManagementSyncTests.java @@ -21,6 +21,7 @@ import com.azure.search.documents.indexes.models.SearchIndex; import com.azure.search.documents.indexes.models.Suggester; import com.azure.search.documents.indexes.models.SynonymMap; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.net.HttpURLConnection; @@ -259,8 +260,8 @@ public void canCreateAndListIndexes() { List result = actual.stream().collect(Collectors.toList()); assertEquals(2, result.size()); - assertEquals(index1.getName(), result.get(0).getName()); - assertEquals(index2.getName(), result.get(1).getName()); + assertObjectEquals(index1, result.get(0), true); + assertObjectEquals(index2, result.get(1), true); } @Test @@ -275,26 +276,14 @@ public void canListIndexesWithSelectedField() { client.createIndex(index2); indexesToDelete.add(index2.getName()); - PagedIterable selectedFieldListResponse = client.listIndexes("name", - generateRequestOptions(), Context.NONE); - List result = selectedFieldListResponse.stream().collect(Collectors.toList()); - - result.forEach(res -> { - assertNotNull(res.getName()); - assertNull(res.getFields()); - assertNull(res.getDefaultScoringProfile()); - assertNull(res.getCorsOptions()); - assertNull(res.getScoringProfiles()); - assertNull(res.getSuggesters()); - assertNull(res.getAnalyzers()); - assertNull(res.getTokenizers()); - assertNull(res.getTokenFilters()); - assertNull(res.getCharFilters()); - }); + PagedIterable selectedFieldListResponse = client.listIndexNames(generateRequestOptions(), Context.NONE); + List result = selectedFieldListResponse.stream().collect(Collectors.toList()); + + result.forEach(Assertions::assertNotNull); assertEquals(2, result.size()); - assertEquals(result.get(0).getName(), index1.getName()); - assertEquals(result.get(1).getName(), index2.getName()); + assertEquals(result.get(0), index1.getName()); + assertEquals(result.get(1), index2.getName()); } @Test 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 1a5e71e99dce..47ff2facd6c6 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 @@ -48,7 +48,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.fail; @@ -190,15 +189,16 @@ public void canCreateAndListIndexerNames() { searchIndexerClient.createIndexer(indexer2); indexersToDelete.add(indexer2.getName()); - Iterator indexersRes = searchIndexerClient.listIndexers("name", generateRequestOptions(), Context.NONE).iterator(); + Iterator indexersRes = searchIndexerClient.listIndexerNames(generateRequestOptions(), Context.NONE) + .iterator(); - SearchIndexer actualIndexer = indexersRes.next(); - assertEquals(indexer1.getName(), actualIndexer.getName()); - assertAllIndexerFieldsNullExceptName(actualIndexer); + String actualIndexer = indexersRes.next(); + assertNotNull(actualIndexer); + assertEquals(indexer1.getName(), actualIndexer); actualIndexer = indexersRes.next(); - assertEquals(indexer2.getName(), actualIndexer.getName()); - assertAllIndexerFieldsNullExceptName(actualIndexer); + assertNotNull(actualIndexer); + assertEquals(indexer2.getName(), actualIndexer); assertFalse(indexersRes.hasNext()); } @@ -813,18 +813,6 @@ void setSameStartTime(SearchIndexer expected, SearchIndexer actual) { expected.getSchedule().setStartTime(actual.getSchedule().getStartTime()); } - void assertAllIndexerFieldsNullExceptName(SearchIndexer indexer) { - assertNull(indexer.getParameters()); - assertNull(indexer.getDataSourceName()); - assertNull(indexer.getDescription()); - assertNull(indexer.getETag()); - assertNull(indexer.getFieldMappings()); - assertNull(indexer.getOutputFieldMappings()); - assertNull(indexer.getSchedule()); - assertNull(indexer.getSkillsetName()); - assertNull(indexer.getTargetIndexName()); - } - void assertStartAndEndTimeValid(IndexerExecutionResult result) { assertNotNull(result.getStartTime()); assertNotEquals(OffsetDateTime.now(), result.getStartTime()); diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/SkillsetManagementSyncTests.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/SkillsetManagementSyncTests.java index b73cc19a05fb..7defcb94d07d 100644 --- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/SkillsetManagementSyncTests.java +++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/SkillsetManagementSyncTests.java @@ -35,6 +35,7 @@ import com.azure.search.documents.indexes.models.TextSplitMode; import com.azure.search.documents.indexes.models.VisualFeature; import com.azure.search.documents.indexes.models.WebApiSkill; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.net.HttpURLConnection; @@ -42,6 +43,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; @@ -51,8 +53,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.fail; @@ -340,12 +340,11 @@ public void canCreateAndListSkillsets() { client.createSkillset(skillset2); skillsetsToDelete.add(skillset2.getName()); - PagedIterable actual = client.listSkillsets(); - List result = actual.stream().collect(Collectors.toList()); + Iterator actual = client.listSkillsets().iterator(); - assertEquals(2, result.size()); - assertEquals(skillset1.getName(), result.get(0).getName()); - assertEquals(skillset2.getName(), result.get(1).getName()); + assertObjectEquals(skillset1, actual.next(), true); + assertObjectEquals(skillset2, actual.next(), true); + assertFalse(actual.hasNext()); } @Test @@ -358,20 +357,15 @@ public void canListSkillsetsWithSelectedField() { client.createSkillset(skillset2); skillsetsToDelete.add(skillset2.getName()); - PagedIterable selectedFieldListResponse = client.listSkillsets("name", generateRequestOptions(), Context.NONE); - List result = selectedFieldListResponse.stream().collect(Collectors.toList()); + PagedIterable selectedFieldListResponse = + client.listSkillsetNames(generateRequestOptions(), Context.NONE); + List result = selectedFieldListResponse.stream().collect(Collectors.toList()); - result.forEach(res -> { - assertNotNull(res.getName()); - assertNull(res.getCognitiveServicesAccount()); - assertNull(res.getDescription()); - assertNull(res.getSkills()); - assertNull(res.getETag()); - }); + result.forEach(Assertions::assertNotNull); assertEquals(2, result.size()); - assertEquals(result.get(0).getName(), skillset1.getName()); - assertEquals(result.get(1).getName(), skillset2.getName()); + assertEquals(result.get(0), skillset1.getName()); + assertEquals(result.get(1), skillset2.getName()); } @Test 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 f55eac44f4c1..b3d29f60efc1 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 @@ -9,22 +9,23 @@ import com.azure.core.util.CoreUtils; import com.azure.search.documents.SearchTestBase; import com.azure.search.documents.indexes.models.SynonymMap; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.net.HttpURLConnection; import java.util.ArrayList; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.stream.Collectors; import static com.azure.search.documents.TestHelpers.assertHttpResponseException; +import static com.azure.search.documents.TestHelpers.assertObjectEquals; import static com.azure.search.documents.TestHelpers.generateRequestOptions; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.fail; @@ -289,20 +290,17 @@ public void canCreateAndDeleteSynonymMap() { public void canCreateAndListSynonymMaps() { SynonymMap synonymMap1 = createTestSynonymMap(); SynonymMap synonymMap2 = createTestSynonymMap(); - Set expectedNames = new HashSet<>(); - expectedNames.add(synonymMap1.getName()); - expectedNames.add(synonymMap2.getName()); client.createSynonymMap(synonymMap1); synonymMapsToDelete.add(synonymMap1.getName()); client.createSynonymMap(synonymMap2); synonymMapsToDelete.add(synonymMap2.getName()); - PagedIterable actual = client.listSynonymMaps(); - List result = actual.stream().collect(Collectors.toList()); + Iterator actual = client.listSynonymMaps().iterator(); - assertEquals(2, result.size()); - expectedNames.containsAll(result); + assertObjectEquals(synonymMap1, actual.next(), true); + assertObjectEquals(synonymMap2, actual.next(), true); + assertFalse(actual.hasNext()); } @Test @@ -318,14 +316,10 @@ public void canListSynonymMapsWithSelectedField() { client.createSynonymMap(synonymMap2); synonymMapsToDelete.add(synonymMap2.getName()); - PagedIterable listResponse = client.listSynonymMaps("name", generateRequestOptions(), Context.NONE); - List result = listResponse.stream().collect(Collectors.toList()); + PagedIterable listResponse = client.listSynonymMapNames(generateRequestOptions(), Context.NONE); + List result = listResponse.stream().collect(Collectors.toList()); - result.forEach(res -> { - assertNotNull(res.getName()); - assertNull(res.getSynonyms()); - assertNull(res.getETag()); - }); + result.forEach(Assertions::assertNotNull); assertEquals(2, result.size()); expectedNames.containsAll(result); diff --git a/sdk/search/azure-search-documents/src/test/resources/session-records/canCreateAndListSynonymMaps.json b/sdk/search/azure-search-documents/src/test/resources/session-records/canCreateAndListSynonymMaps.json index b128c888f481..41842ec025df 100644 --- a/sdk/search/azure-search-documents/src/test/resources/session-records/canCreateAndListSynonymMaps.json +++ b/sdk/search/azure-search-documents/src/test/resources/session-records/canCreateAndListSynonymMaps.json @@ -3,118 +3,128 @@ "Method" : "POST", "Uri" : "https://REDACTED.search.windows.net/synonymmaps?api-version=2019-05-06-Preview", "Headers" : { - "x-ms-client-request-id" : "245974b9-9918-4745-9aee-07a307500ae4", + "User-Agent" : "azsdk-java-azure-search-documents/1.0.0-beta.4 (11.0.6; Windows 10 10.0)", + "x-ms-client-request-id" : "774fc3ec-ffc5-426f-bd05-e50bb50733fa", "Content-Type" : "application/json; charset=utf-8" }, "Response" : { "Pragma" : "no-cache", "retry-after" : "0", - "request-id" : "245974b9-9918-4745-9aee-07a307500ae4", + "request-id" : "774fc3ec-ffc5-426f-bd05-e50bb50733fa", "StatusCode" : "201", - "Date" : "Mon, 11 May 2020 18:11:54 GMT", + "Date" : "Thu, 28 May 2020 19:26:18 GMT", "Strict-Transport-Security" : "max-age=15724800; includeSubDomains", "Cache-Control" : "no-cache", - "client-request-id" : "245974b9-9918-4745-9aee-07a307500ae4", - "ETag" : "W/\"0x8D7F5D6C94C26A2\"", - "elapsed-time" : "20", + "client-request-id" : "774fc3ec-ffc5-426f-bd05-e50bb50733fa", + "ETag" : "W/\"0x8D8033CFF9FFF19\"", + "elapsed-time" : "40", "OData-Version" : "4.0", "Expires" : "-1", - "Content-Length" : "227", - "Body" : "{\"@odata.context\":\"https://alzimmer-search.search.windows.net/$metadata#synonymmaps/$entity\",\"@odata.etag\":\"\\\"0x8D7F5D6C94C26A2\\\"\",\"name\":\"test-synonym64035b5f9e48\",\"format\":\"solr\",\"synonyms\":\"word1,word2\",\"encryptionKey\":null}", + "Content-Length" : "224", + "Body" : "{\"@odata.context\":\"https://sizhu-search.search.windows.net/$metadata#synonymmaps/$entity\",\"@odata.etag\":\"\\\"0x8D8033CFF9FFF19\\\"\",\"name\":\"test-synonym350036c22684\",\"format\":\"solr\",\"synonyms\":\"word1,word2\",\"encryptionKey\":null}", "Preference-Applied" : "odata.include-annotations=\"*\"", + "x-ms-client-request-id" : "774fc3ec-ffc5-426f-bd05-e50bb50733fa", "Content-Type" : "application/json; odata.metadata=minimal", - "Location" : "https://alzimmer-search.search.windows.net/synonymmaps('test-synonym64035b5f9e48')?api-version=2019-05-06-Preview" + "Location" : "https://sizhu-search.search.windows.net/synonymmaps('test-synonym350036c22684')?api-version=2019-05-06-Preview" }, "Exception" : null }, { "Method" : "POST", "Uri" : "https://REDACTED.search.windows.net/synonymmaps?api-version=2019-05-06-Preview", "Headers" : { - "x-ms-client-request-id" : "92607e4d-edfe-46c3-a581-693179059ebc", + "User-Agent" : "azsdk-java-azure-search-documents/1.0.0-beta.4 (11.0.6; Windows 10 10.0)", + "x-ms-client-request-id" : "9d2b2ddf-ef31-4306-b68d-bcbbd79c8cf4", "Content-Type" : "application/json; charset=utf-8" }, "Response" : { "Pragma" : "no-cache", "retry-after" : "0", - "request-id" : "92607e4d-edfe-46c3-a581-693179059ebc", + "request-id" : "9d2b2ddf-ef31-4306-b68d-bcbbd79c8cf4", "StatusCode" : "201", - "Date" : "Mon, 11 May 2020 18:11:54 GMT", + "Date" : "Thu, 28 May 2020 19:26:18 GMT", "Strict-Transport-Security" : "max-age=15724800; includeSubDomains", "Cache-Control" : "no-cache", - "client-request-id" : "92607e4d-edfe-46c3-a581-693179059ebc", - "ETag" : "W/\"0x8D7F5D6C95305AF\"", - "elapsed-time" : "24", + "client-request-id" : "9d2b2ddf-ef31-4306-b68d-bcbbd79c8cf4", + "ETag" : "W/\"0x8D8033CFFB00787\"", + "elapsed-time" : "20", "OData-Version" : "4.0", "Expires" : "-1", - "Content-Length" : "227", - "Body" : "{\"@odata.context\":\"https://alzimmer-search.search.windows.net/$metadata#synonymmaps/$entity\",\"@odata.etag\":\"\\\"0x8D7F5D6C95305AF\\\"\",\"name\":\"test-synonym0530187f46cc\",\"format\":\"solr\",\"synonyms\":\"word1,word2\",\"encryptionKey\":null}", + "Content-Length" : "224", + "Body" : "{\"@odata.context\":\"https://sizhu-search.search.windows.net/$metadata#synonymmaps/$entity\",\"@odata.etag\":\"\\\"0x8D8033CFFB00787\\\"\",\"name\":\"test-synonym949944aabfea\",\"format\":\"solr\",\"synonyms\":\"word1,word2\",\"encryptionKey\":null}", "Preference-Applied" : "odata.include-annotations=\"*\"", + "x-ms-client-request-id" : "9d2b2ddf-ef31-4306-b68d-bcbbd79c8cf4", "Content-Type" : "application/json; odata.metadata=minimal", - "Location" : "https://alzimmer-search.search.windows.net/synonymmaps('test-synonym0530187f46cc')?api-version=2019-05-06-Preview" + "Location" : "https://sizhu-search.search.windows.net/synonymmaps('test-synonym949944aabfea')?api-version=2019-05-06-Preview" }, "Exception" : null }, { "Method" : "GET", "Uri" : "https://REDACTED.search.windows.net/synonymmaps?api-version=2019-05-06-Preview", "Headers" : { - "x-ms-client-request-id" : "f0188538-a57a-4391-aa44-eb4cb2f5fba6" + "User-Agent" : "azsdk-java-azure-search-documents/1.0.0-beta.4 (11.0.6; Windows 10 10.0)", + "x-ms-client-request-id" : "4a5465c4-9199-4723-96d5-5e0cc8edd7bd" }, "Response" : { "Pragma" : "no-cache", "retry-after" : "0", - "request-id" : "f0188538-a57a-4391-aa44-eb4cb2f5fba6", + "request-id" : "4a5465c4-9199-4723-96d5-5e0cc8edd7bd", "StatusCode" : "200", - "Date" : "Mon, 11 May 2020 18:11:54 GMT", + "Date" : "Thu, 28 May 2020 19:26:18 GMT", "Strict-Transport-Security" : "max-age=15724800; includeSubDomains", "Cache-Control" : "no-cache", - "client-request-id" : "f0188538-a57a-4391-aa44-eb4cb2f5fba6", - "elapsed-time" : "14", + "client-request-id" : "4a5465c4-9199-4723-96d5-5e0cc8edd7bd", + "elapsed-time" : "37", "OData-Version" : "4.0", "Expires" : "-1", - "Content-Length" : "367", - "Body" : "{\"@odata.context\":\"https://alzimmer-search.search.windows.net/$metadata#synonymmaps\",\"value\":[{\"@odata.etag\":\"\\\"0x8D7F5D6C95305AF\\\"\",\"name\":\"test-synonym0530187f46cc\",\"format\":\"solr\",\"synonyms\":\"word1,word2\",\"encryptionKey\":null},{\"@odata.etag\":\"\\\"0x8D7F5D6C94C26A2\\\"\",\"name\":\"test-synonym64035b5f9e48\",\"format\":\"solr\",\"synonyms\":\"word1,word2\",\"encryptionKey\":null}]}", + "Content-Length" : "364", + "Body" : "{\"@odata.context\":\"https://sizhu-search.search.windows.net/$metadata#synonymmaps\",\"value\":[{\"@odata.etag\":\"\\\"0x8D8033CFF9FFF19\\\"\",\"name\":\"test-synonym350036c22684\",\"format\":\"solr\",\"synonyms\":\"word1,word2\",\"encryptionKey\":null},{\"@odata.etag\":\"\\\"0x8D8033CFFB00787\\\"\",\"name\":\"test-synonym949944aabfea\",\"format\":\"solr\",\"synonyms\":\"word1,word2\",\"encryptionKey\":null}]}", "Preference-Applied" : "odata.include-annotations=\"*\"", + "x-ms-client-request-id" : "4a5465c4-9199-4723-96d5-5e0cc8edd7bd", "Content-Type" : "application/json; odata.metadata=minimal" }, "Exception" : null }, { "Method" : "DELETE", - "Uri" : "https://REDACTED.search.windows.net/synonymmaps('test-synonym64035b5f9e48')?api-version=2019-05-06-Preview", + "Uri" : "https://REDACTED.search.windows.net/synonymmaps('test-synonym350036c22684')?api-version=2019-05-06-Preview", "Headers" : { - "x-ms-client-request-id" : "07bc9d12-f45e-4e07-b85a-a4c2044e8f2c" + "User-Agent" : "azsdk-java-azure-search-documents/1.0.0-beta.4 (11.0.6; Windows 10 10.0)", + "x-ms-client-request-id" : "888d0d0e-08fb-4b5b-87e2-3586f000daab" }, "Response" : { "Strict-Transport-Security" : "max-age=15724800; includeSubDomains", "Cache-Control" : "no-cache", - "client-request-id" : "07bc9d12-f45e-4e07-b85a-a4c2044e8f2c", - "elapsed-time" : "14", + "client-request-id" : "888d0d0e-08fb-4b5b-87e2-3586f000daab", + "elapsed-time" : "10", "Expires" : "-1", "Pragma" : "no-cache", "retry-after" : "0", - "request-id" : "07bc9d12-f45e-4e07-b85a-a4c2044e8f2c", + "request-id" : "888d0d0e-08fb-4b5b-87e2-3586f000daab", "StatusCode" : "204", - "Date" : "Mon, 11 May 2020 18:11:54 GMT" + "Date" : "Thu, 28 May 2020 19:26:18 GMT", + "x-ms-client-request-id" : "888d0d0e-08fb-4b5b-87e2-3586f000daab" }, "Exception" : null }, { "Method" : "DELETE", - "Uri" : "https://REDACTED.search.windows.net/synonymmaps('test-synonym0530187f46cc')?api-version=2019-05-06-Preview", + "Uri" : "https://REDACTED.search.windows.net/synonymmaps('test-synonym949944aabfea')?api-version=2019-05-06-Preview", "Headers" : { - "x-ms-client-request-id" : "bdaaa4df-ae8f-4f4e-9ab0-00bc61df0ca7" + "User-Agent" : "azsdk-java-azure-search-documents/1.0.0-beta.4 (11.0.6; Windows 10 10.0)", + "x-ms-client-request-id" : "fd0741d0-d027-409b-bcd9-1b79beaa3a7b" }, "Response" : { "Strict-Transport-Security" : "max-age=15724800; includeSubDomains", "Cache-Control" : "no-cache", - "client-request-id" : "bdaaa4df-ae8f-4f4e-9ab0-00bc61df0ca7", - "elapsed-time" : "13", + "client-request-id" : "fd0741d0-d027-409b-bcd9-1b79beaa3a7b", + "elapsed-time" : "16", "Expires" : "-1", "Pragma" : "no-cache", "retry-after" : "0", - "request-id" : "bdaaa4df-ae8f-4f4e-9ab0-00bc61df0ca7", + "request-id" : "fd0741d0-d027-409b-bcd9-1b79beaa3a7b", "StatusCode" : "204", - "Date" : "Mon, 11 May 2020 18:11:54 GMT" + "Date" : "Thu, 28 May 2020 19:26:19 GMT", + "x-ms-client-request-id" : "fd0741d0-d027-409b-bcd9-1b79beaa3a7b" }, "Exception" : null } ], - "variables" : [ "test-synonym64035b5f9e48", "test-synonym0530187f46cc" ] + "variables" : [ "test-synonym350036c22684", "test-synonym949944aabfea" ] } \ No newline at end of file