diff --git a/sdk/search/azure-search-documents/_metadata.json b/sdk/search/azure-search-documents/_metadata.json index 66892d1cb69d..26bd40e914cd 100644 --- a/sdk/search/azure-search-documents/_metadata.json +++ b/sdk/search/azure-search-documents/_metadata.json @@ -1,3 +1,6 @@ { - "apiVersion": "2025-11-01-preview" + "apiVersion": "2025-11-01-preview", + "apiVersions": { + "Search": "2025-11-01-preview" + } } \ No newline at end of file diff --git a/sdk/search/azure-search-documents/apiview-properties.json b/sdk/search/azure-search-documents/apiview-properties.json index f26cb866984b..89a70bf4d99a 100644 --- a/sdk/search/azure-search-documents/apiview-properties.json +++ b/sdk/search/azure-search-documents/apiview-properties.json @@ -226,6 +226,7 @@ "azure.search.documents.indexes.models.SearchIndexKnowledgeSource": "Search.SearchIndexKnowledgeSource", "azure.search.documents.indexes.models.SearchIndexKnowledgeSourceParameters": "Search.SearchIndexKnowledgeSourceParameters", "azure.search.documents.knowledgebases.models.SearchIndexKnowledgeSourceParams": "Search.SearchIndexKnowledgeSourceParams", + "azure.search.documents.indexes.models.SearchIndexResponse": "Search.SearchIndexResponse", "azure.search.documents.models.SearchRequest": "Search.SearchRequest", "azure.search.documents.indexes.models.SearchResourceEncryptionKey": "Search.SearchResourceEncryptionKey", "azure.search.documents.models.SearchResult": "Search.SearchResult", @@ -396,8 +397,8 @@ "azure.search.documents.aio.SearchIndexClient.create_synonym_map": "Customizations.SearchIndexClient.SynonymMaps.create", "azure.search.documents.SearchIndexClient.get_index": "Customizations.SearchIndexClient.Indexes.get", "azure.search.documents.aio.SearchIndexClient.get_index": "Customizations.SearchIndexClient.Indexes.get", - "azure.search.documents.SearchIndexClient.list_indexes": "Customizations.SearchIndexClient.Indexes.list", - "azure.search.documents.aio.SearchIndexClient.list_indexes": "Customizations.SearchIndexClient.Indexes.list", + "azure.search.documents.SearchIndexClient.list_indexes_with_selected_properties": "Customizations.SearchIndexClient.Indexes.listWithSelectedProperties", + "azure.search.documents.aio.SearchIndexClient.list_indexes_with_selected_properties": "Customizations.SearchIndexClient.Indexes.listWithSelectedProperties", "azure.search.documents.SearchIndexClient.create_index": "Customizations.SearchIndexClient.Indexes.create", "azure.search.documents.aio.SearchIndexClient.create_index": "Customizations.SearchIndexClient.Indexes.create", "azure.search.documents.SearchIndexClient.get_alias": "Customizations.SearchIndexClient.Aliases.get", diff --git a/sdk/search/azure-search-documents/azure/search/documents/_client.py b/sdk/search/azure-search-documents/azure/search/documents/_client.py index 5f688aa13b44..f96d7ea85bb4 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_client.py @@ -34,9 +34,9 @@ class SearchClient(_SearchClientOperationsMixin): ~azure.core.credentials.TokenCredential :param index_name: The name of the index. Required. :type index_name: str - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/search/azure-search-documents/azure/search/documents/_configuration.py b/sdk/search/azure-search-documents/azure/search/documents/_configuration.py index f6f346ca1211..dfe36d2d3450 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_configuration.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_configuration.py @@ -31,9 +31,9 @@ class SearchClientConfiguration: # pylint: disable=too-many-instance-attributes ~azure.core.credentials.TokenCredential :param index_name: The name of the index. Required. :type index_name: str - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/search/azure-search-documents/azure/search/documents/aio/_client.py b/sdk/search/azure-search-documents/azure/search/documents/aio/_client.py index 5634eb8a97d5..e2aa4dc24ac6 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/aio/_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/aio/_client.py @@ -34,9 +34,9 @@ class SearchClient(_SearchClientOperationsMixin): ~azure.core.credentials_async.AsyncTokenCredential :param index_name: The name of the index. Required. :type index_name: str - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/search/azure-search-documents/azure/search/documents/aio/_configuration.py b/sdk/search/azure-search-documents/azure/search/documents/aio/_configuration.py index 34ad0564cab6..5063e52eb2c9 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/aio/_configuration.py +++ b/sdk/search/azure-search-documents/azure/search/documents/aio/_configuration.py @@ -31,9 +31,9 @@ class SearchClientConfiguration: # pylint: disable=too-many-instance-attributes ~azure.core.credentials_async.AsyncTokenCredential :param index_name: The name of the index. Required. :type index_name: str - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/_client.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/_client.py index 54c2e85631d1..4a3b1a14824f 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/_client.py @@ -32,9 +32,9 @@ class SearchIndexClient(_SearchIndexClientOperationsMixin): credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ @@ -111,9 +111,9 @@ class SearchIndexerClient(_SearchIndexerClientOperationsMixin): credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/_configuration.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/_configuration.py index a1c66e4d109e..ccbce6e25376 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/_configuration.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/_configuration.py @@ -29,9 +29,9 @@ class SearchIndexClientConfiguration: # pylint: disable=too-many-instance-attri credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ @@ -84,9 +84,9 @@ class SearchIndexerClientConfiguration: # pylint: disable=too-many-instance-att credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/_operations/_operations.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/_operations/_operations.py index fe1ec10a1fb3..9c6bdec0d3fc 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/_operations/_operations.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/_operations/_operations.py @@ -286,7 +286,28 @@ def build_search_index_get_index_request(name: str, **kwargs: Any) -> HttpReques return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_search_index_list_indexes_request(*, select: Optional[list[str]] = None, **kwargs: Any) -> HttpRequest: +def build_search_index_list_indexes_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-11-01-preview")) + accept = _headers.pop("Accept", "application/json;odata.metadata=minimal") + + # Construct URL + _url = "/indexes" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_search_index_list_indexes_with_selected_properties_request( # pylint: disable=name-too-long + *, select: Optional[list[str]] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2210,13 +2231,9 @@ def get_index(self, name: str, **kwargs: Any) -> _models1.SearchIndex: return deserialized # type: ignore @distributed_trace - def list_indexes(self, *, select: Optional[list[str]] = None, **kwargs: Any) -> ItemPaged["_models1.SearchIndex"]: + def _list_indexes(self, **kwargs: Any) -> ItemPaged["_models1.SearchIndex"]: """Lists all indexes available for a search service. - :keyword select: Selects which top-level properties to retrieve. Specified as a comma-separated - list of JSON property names, or '*' for all properties. The default is all properties. Default - value is None. - :paramtype select: list[str] :return: An iterator like instance of SearchIndex :rtype: ~azure.core.paging.ItemPaged[~azure.search.documents.indexes.models.SearchIndex] :raises ~azure.core.exceptions.HttpResponseError: @@ -2238,7 +2255,6 @@ def prepare_request(next_link=None): if not next_link: _request = build_search_index_list_indexes_request( - select=select, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2300,6 +2316,100 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) + @distributed_trace + def _list_indexes_with_selected_properties( + self, *, select: Optional[list[str]] = None, **kwargs: Any + ) -> ItemPaged["_models1._models.SearchIndexResponse"]: + """Lists all indexes available for a search service. + + :keyword select: Selects which top-level properties to retrieve. Specified as a comma-separated + list of JSON property names, or '*' for all properties. The default is all properties. Default + value is None. + :paramtype select: list[str] + :return: An iterator like instance of SearchIndexResponse + :rtype: + ~azure.core.paging.ItemPaged[~azure.search.documents.indexes.models._models.SearchIndexResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models1._models.SearchIndexResponse]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_search_index_list_indexes_with_selected_properties_request( + select=select, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(list[_models1._models.SearchIndexResponse], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models2.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + @overload def create_index( self, index: _models1.SearchIndex, *, content_type: str = "application/json", **kwargs: Any diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/_operations/_patch.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/_operations/_patch.py index d721de4dbe5b..139fb1ad179b 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/_operations/_patch.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/_operations/_patch.py @@ -15,6 +15,7 @@ from azure.core.tracing.decorator import distributed_trace from .. import models as _models +from ..models._models import SearchIndexResponse as _SearchIndexResponse from ._operations import ( _SearchIndexClientOperationsMixin as _SearchIndexClientOperationsMixinGenerated, _SearchIndexerClientOperationsMixin as _SearchIndexerClientOperationsMixinGenerated, @@ -24,6 +25,37 @@ import azure.search.documents +def _convert_index_response(response: _SearchIndexResponse) -> _models.SearchIndex: + """Convert a SearchIndexResponse to a SearchIndex. + + :param response: The SearchIndexResponse to convert. + :type response: ~azure.search.documents.indexes.models._models.SearchIndexResponse + :return: The converted SearchIndex. + :rtype: ~azure.search.documents.indexes.models.SearchIndex + """ + return _models.SearchIndex( + name=response.name, + fields=response.fields or [], + description=response.description, + scoring_profiles=response.scoring_profiles, + default_scoring_profile=response.default_scoring_profile, + cors_options=response.cors_options, + suggesters=response.suggesters, + analyzers=response.analyzers, + tokenizers=response.tokenizers, + token_filters=response.token_filters, + char_filters=response.char_filters, + normalizers=response.normalizers, + encryption_key=response.encryption_key, + similarity=response.similarity, + semantic_search=response.semantic, + vector_search=response.vector_search, + permission_filter_option=response.permission_filter_option, + purview_enabled=response.purview_enabled, + e_tag=response.e_tag, + ) + + class _SearchIndexClientOperationsMixin(_SearchIndexClientOperationsMixinGenerated): """Custom operations mixin for SearchIndexClient.""" @@ -325,6 +357,29 @@ def delete_knowledge_source( **kwargs, ) + @distributed_trace + def list_indexes(self, *, select: Optional[List[str]] = None, **kwargs: Any) -> ItemPaged[_models.SearchIndex]: + """Lists all indexes available for a search service. + + :keyword select: Selects which top-level properties to retrieve. Specified as a comma-separated + list of JSON property names, or '*' for all properties. The default is all properties. + Default value is None. + :paramtype select: list[str] + :return: An iterator like instance of SearchIndex + :rtype: ~azure.core.paging.ItemPaged[~azure.search.documents.indexes.models.SearchIndex] + :raises ~azure.core.exceptions.HttpResponseError: + """ + if select is not None: + return cast( + ItemPaged[_models.SearchIndex], + self._list_indexes_with_selected_properties( + select=select, + cls=lambda objs: [_convert_index_response(x) for x in objs], + **kwargs, + ), + ) + return self._list_indexes(**kwargs) + @distributed_trace def list_index_names(self, **kwargs: Any) -> ItemPaged[str]: """Lists the names of all indexes available for a search service. @@ -333,7 +388,7 @@ def list_index_names(self, **kwargs: Any) -> ItemPaged[str]: :rtype: ~azure.core.paging.ItemPaged[str] :raises ~azure.core.exceptions.HttpResponseError: """ - names = self.list_indexes(cls=lambda objs: [x.name for x in objs], **kwargs) + names = self._list_indexes(cls=lambda objs: [x.name for x in objs], **kwargs) return cast(ItemPaged[str], names) @distributed_trace diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_client.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_client.py index 8827716ecdcf..abfade0135cc 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_client.py @@ -32,9 +32,9 @@ class SearchIndexClient(_SearchIndexClientOperationsMixin): credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ @@ -115,9 +115,9 @@ class SearchIndexerClient(_SearchIndexerClientOperationsMixin): credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_configuration.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_configuration.py index c50be6dff29a..ecf97247abc0 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_configuration.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_configuration.py @@ -29,9 +29,9 @@ class SearchIndexClientConfiguration: # pylint: disable=too-many-instance-attri credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ @@ -86,9 +86,9 @@ class SearchIndexerClientConfiguration: # pylint: disable=too-many-instance-att credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_operations/_operations.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_operations/_operations.py index 94160d3a5405..b3e598bea751 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_operations/_operations.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_operations/_operations.py @@ -65,6 +65,7 @@ build_search_index_list_aliases_request, build_search_index_list_index_stats_summary_request, build_search_index_list_indexes_request, + build_search_index_list_indexes_with_selected_properties_request, build_search_index_list_knowledge_bases_request, build_search_index_list_knowledge_sources_request, build_search_indexer_create_data_source_connection_request, @@ -838,24 +839,111 @@ async def get_index(self, name: str, **kwargs: Any) -> _models2.SearchIndex: return deserialized # type: ignore @distributed_trace - def list_indexes( + def _list_indexes(self, **kwargs: Any) -> AsyncItemPaged["_models2.SearchIndex"]: + """Lists all indexes available for a search service. + + :return: An iterator like instance of SearchIndex + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.search.documents.indexes.models.SearchIndex] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models2.SearchIndex]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_search_index_list_indexes_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(list[_models2.SearchIndex], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models3.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def _list_indexes_with_selected_properties( self, *, select: Optional[list[str]] = None, **kwargs: Any - ) -> AsyncItemPaged["_models2.SearchIndex"]: + ) -> AsyncItemPaged["_models2._models.SearchIndexResponse"]: """Lists all indexes available for a search service. :keyword select: Selects which top-level properties to retrieve. Specified as a comma-separated list of JSON property names, or '*' for all properties. The default is all properties. Default value is None. :paramtype select: list[str] - :return: An iterator like instance of SearchIndex + :return: An iterator like instance of SearchIndexResponse :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.search.documents.indexes.models.SearchIndex] + ~azure.core.async_paging.AsyncItemPaged[~azure.search.documents.indexes.models._models.SearchIndexResponse] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[list[_models2.SearchIndex]] = kwargs.pop("cls", None) + cls: ClsType[list[_models2._models.SearchIndexResponse]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -868,7 +956,7 @@ def list_indexes( def prepare_request(next_link=None): if not next_link: - _request = build_search_index_list_indexes_request( + _request = build_search_index_list_indexes_with_selected_properties_request( select=select, api_version=self._config.api_version, headers=_headers, @@ -905,7 +993,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(list[_models2.SearchIndex], deserialized.get("value", [])) + list_of_elem = _deserialize(list[_models2._models.SearchIndexResponse], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_operations/_patch.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_operations/_patch.py index 1a698a3a7a36..3a0b6b321e96 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_operations/_patch.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_operations/_patch.py @@ -16,6 +16,7 @@ from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models +from ..._operations._patch import _convert_index_response from ._operations import ( _SearchIndexClientOperationsMixin as _SearchIndexClientOperationsMixinGenerated, _SearchIndexerClientOperationsMixin as _SearchIndexerClientOperationsMixinGenerated, @@ -336,6 +337,29 @@ async def delete_knowledge_source( **kwargs, ) + @distributed_trace + def list_indexes(self, *, select: Optional[List[str]] = None, **kwargs: Any) -> AsyncItemPaged[_models.SearchIndex]: + """Lists all indexes available for a search service. + + :keyword select: Selects which top-level properties to retrieve. Specified as a comma-separated + list of JSON property names, or '*' for all properties. The default is all properties. + Default value is None. + :paramtype select: list[str] + :return: An async iterator like instance of SearchIndex + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.search.documents.indexes.models.SearchIndex] + :raises ~azure.core.exceptions.HttpResponseError: + """ + if select is not None: + return cast( + AsyncItemPaged[_models.SearchIndex], + self._list_indexes_with_selected_properties( + select=select, + cls=lambda objs: [_convert_index_response(x) for x in objs], + **kwargs, + ), + ) + return self._list_indexes(**kwargs) + @distributed_trace def list_index_names(self, **kwargs: Any) -> AsyncItemPaged[str]: """Lists the names of all indexes available for a search service. @@ -344,7 +368,7 @@ def list_index_names(self, **kwargs: Any) -> AsyncItemPaged[str]: :rtype: ~azure.core.async_paging.AsyncItemPaged[str] :raises ~azure.core.exceptions.HttpResponseError: """ - names = self.list_indexes(cls=lambda objs: [x.name for x in objs], **kwargs) + names = self._list_indexes(cls=lambda objs: [x.name for x in objs], **kwargs) return cast(AsyncItemPaged[str], names) @distributed_trace_async diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/models/_models.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/models/_models.py index fb205c60d3f1..bcfd8a516667 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/models/_models.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/models/_models.py @@ -9617,6 +9617,182 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class SearchIndexResponse(_Model): + """Represents a search index definition, which describes the fields and search behavior of an + index. + + :ivar name: The name of the index. Required. + :vartype name: str + :ivar description: The description of the index. + :vartype description: str + :ivar fields: The fields of the index. + :vartype fields: list[~azure.search.documents.indexes.models.SearchField] + :ivar scoring_profiles: The scoring profiles for the index. + :vartype scoring_profiles: list[~azure.search.documents.indexes.models.ScoringProfile] + :ivar default_scoring_profile: The name of the scoring profile to use if none is specified in + the query. If this property is not set and no scoring profile is specified in the query, then + default scoring (tf-idf) will be used. + :vartype default_scoring_profile: str + :ivar cors_options: Options to control Cross-Origin Resource Sharing (CORS) for the index. + :vartype cors_options: ~azure.search.documents.indexes.models.CorsOptions + :ivar suggesters: The suggesters for the index. + :vartype suggesters: list[~azure.search.documents.indexes.models.SearchSuggester] + :ivar analyzers: The analyzers for the index. + :vartype analyzers: list[~azure.search.documents.indexes.models.LexicalAnalyzer] + :ivar tokenizers: The tokenizers for the index. + :vartype tokenizers: list[~azure.search.documents.indexes.models.LexicalTokenizer] + :ivar token_filters: The token filters for the index. + :vartype token_filters: list[~azure.search.documents.indexes.models.TokenFilter] + :ivar char_filters: The character filters for the index. + :vartype char_filters: list[~azure.search.documents.indexes.models.CharFilter] + :ivar normalizers: The normalizers for the index. + :vartype normalizers: list[~azure.search.documents.indexes.models.LexicalNormalizer] + :ivar encryption_key: A description of an encryption key that you create in Azure Key Vault. + This key is used to provide an additional level of encryption-at-rest for your data when you + want full assurance that no one, not even Microsoft, can decrypt your data. Once you have + encrypted your data, it will always remain encrypted. The search service will ignore attempts + to set this property to null. You can change this property as needed if you want to rotate your + encryption key; Your data will be unaffected. Encryption with customer-managed keys is not + available for free search services, and is only available for paid services created on or after + January 1, 2019. + :vartype encryption_key: ~azure.search.documents.indexes.models.SearchResourceEncryptionKey + :ivar similarity: The type of similarity algorithm to be used when scoring and ranking the + documents matching a search query. The similarity algorithm can only be defined at index + creation time and cannot be modified on existing indexes. If null, the ClassicSimilarity + algorithm is used. + :vartype similarity: ~azure.search.documents.indexes.models.SimilarityAlgorithm + :ivar semantic: Defines parameters for a search index that influence semantic capabilities. + :vartype semantic: ~azure.search.documents.indexes.models.SemanticSearch + :ivar vector_search: Contains configuration options related to vector search. + :vartype vector_search: ~azure.search.documents.indexes.models.VectorSearch + :ivar permission_filter_option: A value indicating whether permission filtering is enabled for + the index. Known values are: "enabled" and "disabled". + :vartype permission_filter_option: str or + ~azure.search.documents.indexes.models.SearchIndexPermissionFilterOption + :ivar purview_enabled: A value indicating whether Purview is enabled for the index. + :vartype purview_enabled: bool + :ivar e_tag: The ETag of the index. + :vartype e_tag: str + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the index. Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The description of the index.""" + fields: Optional[list["_models.SearchField"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The fields of the index.""" + scoring_profiles: Optional[list["_models.ScoringProfile"]] = rest_field( + name="scoringProfiles", visibility=["read", "create", "update", "delete", "query"] + ) + """The scoring profiles for the index.""" + default_scoring_profile: Optional[str] = rest_field( + name="defaultScoringProfile", visibility=["read", "create", "update", "delete", "query"] + ) + """The name of the scoring profile to use if none is specified in the query. If this property is + not set and no scoring profile is specified in the query, then default scoring (tf-idf) will be + used.""" + cors_options: Optional["_models.CorsOptions"] = rest_field( + name="corsOptions", visibility=["read", "create", "update", "delete", "query"] + ) + """Options to control Cross-Origin Resource Sharing (CORS) for the index.""" + suggesters: Optional[list["_models.SearchSuggester"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The suggesters for the index.""" + analyzers: Optional[list["_models.LexicalAnalyzer"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The analyzers for the index.""" + tokenizers: Optional[list["_models.LexicalTokenizer"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The tokenizers for the index.""" + token_filters: Optional[list["_models.TokenFilter"]] = rest_field( + name="tokenFilters", visibility=["read", "create", "update", "delete", "query"] + ) + """The token filters for the index.""" + char_filters: Optional[list["_models.CharFilter"]] = rest_field( + name="charFilters", visibility=["read", "create", "update", "delete", "query"] + ) + """The character filters for the index.""" + normalizers: Optional[list["_models.LexicalNormalizer"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The normalizers for the index.""" + encryption_key: Optional["_models.SearchResourceEncryptionKey"] = rest_field( + name="encryptionKey", visibility=["read", "create", "update", "delete", "query"] + ) + """A description of an encryption key that you create in Azure Key Vault. This key is used to + provide an additional level of encryption-at-rest for your data when you want full assurance + that no one, not even Microsoft, can decrypt your data. Once you have encrypted your data, it + will always remain encrypted. The search service will ignore attempts to set this property to + null. You can change this property as needed if you want to rotate your encryption key; Your + data will be unaffected. Encryption with customer-managed keys is not available for free search + services, and is only available for paid services created on or after January 1, 2019.""" + similarity: Optional["_models.SimilarityAlgorithm"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of similarity algorithm to be used when scoring and ranking the documents matching a + search query. The similarity algorithm can only be defined at index creation time and cannot be + modified on existing indexes. If null, the ClassicSimilarity algorithm is used.""" + semantic: Optional["_models.SemanticSearch"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines parameters for a search index that influence semantic capabilities.""" + vector_search: Optional["_models.VectorSearch"] = rest_field( + name="vectorSearch", visibility=["read", "create", "update", "delete", "query"] + ) + """Contains configuration options related to vector search.""" + permission_filter_option: Optional[Union[str, "_models.SearchIndexPermissionFilterOption"]] = rest_field( + name="permissionFilterOption", visibility=["read", "create", "update", "delete", "query"] + ) + """A value indicating whether permission filtering is enabled for the index. Known values are: + \"enabled\" and \"disabled\".""" + purview_enabled: Optional[bool] = rest_field( + name="purviewEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """A value indicating whether Purview is enabled for the index.""" + e_tag: Optional[str] = rest_field(name="@odata.etag", visibility=["read", "create", "update", "delete", "query"]) + """The ETag of the index.""" + + @overload + def __init__( + self, + *, + name: str, + description: Optional[str] = None, + fields: Optional[list["_models.SearchField"]] = None, + scoring_profiles: Optional[list["_models.ScoringProfile"]] = None, + default_scoring_profile: Optional[str] = None, + cors_options: Optional["_models.CorsOptions"] = None, + suggesters: Optional[list["_models.SearchSuggester"]] = None, + analyzers: Optional[list["_models.LexicalAnalyzer"]] = None, + tokenizers: Optional[list["_models.LexicalTokenizer"]] = None, + token_filters: Optional[list["_models.TokenFilter"]] = None, + char_filters: Optional[list["_models.CharFilter"]] = None, + normalizers: Optional[list["_models.LexicalNormalizer"]] = None, + encryption_key: Optional["_models.SearchResourceEncryptionKey"] = None, + similarity: Optional["_models.SimilarityAlgorithm"] = None, + semantic: Optional["_models.SemanticSearch"] = None, + vector_search: Optional["_models.VectorSearch"] = None, + permission_filter_option: Optional[Union[str, "_models.SearchIndexPermissionFilterOption"]] = None, + purview_enabled: Optional[bool] = None, + e_tag: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class SearchResourceEncryptionKey(_Model): """A customer-managed encryption key in Azure Key Vault. Keys that you create and manage can be used to encrypt or decrypt data-at-rest, such as indexes and synonym maps. diff --git a/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/_client.py b/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/_client.py index fcb1e21616ec..dc6edd562aa6 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/_client.py @@ -32,9 +32,9 @@ class KnowledgeBaseRetrievalClient(_KnowledgeBaseRetrievalClientOperationsMixin) credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/_configuration.py b/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/_configuration.py index 425408a1c073..f7ab40eddeb8 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/_configuration.py +++ b/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/_configuration.py @@ -29,9 +29,9 @@ class KnowledgeBaseRetrievalClientConfiguration: # pylint: disable=too-many-ins credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/aio/_client.py b/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/aio/_client.py index 0bbbb8cd4366..3e7834244a6a 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/aio/_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/aio/_client.py @@ -32,9 +32,9 @@ class KnowledgeBaseRetrievalClient(_KnowledgeBaseRetrievalClientOperationsMixin) credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/aio/_configuration.py b/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/aio/_configuration.py index ec28807286a4..81dada9e9ccb 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/aio/_configuration.py +++ b/sdk/search/azure-search-documents/azure/search/documents/knowledgebases/aio/_configuration.py @@ -29,9 +29,9 @@ class KnowledgeBaseRetrievalClientConfiguration: # pylint: disable=too-many-ins credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are + "2025-11-01-preview" and None. Default value is "2025-11-01-preview". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/search/azure-search-documents/azure/search/documents/models/_patch.py b/sdk/search/azure-search-documents/azure/search/documents/models/_patch.py index 01d2a43fad0f..1a047214579e 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/models/_patch.py +++ b/sdk/search/azure-search-documents/azure/search/documents/models/_patch.py @@ -18,6 +18,7 @@ # Backward-compatible alias: IS was renamed to IS_ENUM to avoid conflict with Python keyword ScoringStatistics.Global = ScoringStatistics.GLOBAL_ENUM # type: ignore[attr-defined] + def _flatten_args(args: Tuple[Union[List[Dict[Any, Any]], List[List[Dict[Any, Any]]]], ...]) -> List[Dict]: """Flatten variadic arguments into a single list of documents.