diff --git a/sdk/search/azure-mgmt-search/_meta.json b/sdk/search/azure-mgmt-search/_meta.json index fd859248c293..1a9377fd1041 100644 --- a/sdk/search/azure-mgmt-search/_meta.json +++ b/sdk/search/azure-mgmt-search/_meta.json @@ -1,11 +1,11 @@ { - "commit": "33a7dbc1743fdacb8e2259011a035154a98cad66", + "commit": "ebc524a1ecb5abadf02838d7ead543d0e70c408b", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.9.7", "use": [ - "@autorest/python@6.2.16", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.7.1", + "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/search/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.2.16 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/search/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", "readme": "specification/search/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/_configuration.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/_configuration.py index 24b8b8361c5c..694256fcb159 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/_configuration.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,14 +30,14 @@ class SearchManagementClientConfiguration(Configuration): # pylint: disable=too :param subscription_id: The unique identifier for a Microsoft Azure subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-09-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SearchManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", "2022-09-01") + api_version: str = kwargs.pop("api_version", "2023-11-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/_search_management_client.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/_search_management_client.py index eb9cd7e82f9e..a3350dce322c 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/_search_management_client.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/_search_management_client.py @@ -21,8 +21,10 @@ PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueryKeysOperations, + SearchManagementClientOperationsMixin, ServicesOperations, SharedPrivateLinkResourcesOperations, + UsagesOperations, ) if TYPE_CHECKING: @@ -30,7 +32,9 @@ from azure.core.credentials import TokenCredential -class SearchManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class SearchManagementClient( + SearchManagementClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Client that can be used to manage Azure Cognitive Search services and API keys. :ivar operations: Operations operations @@ -49,6 +53,8 @@ class SearchManagementClient: # pylint: disable=client-accepts-api-version-keyw :ivar shared_private_link_resources: SharedPrivateLinkResourcesOperations operations :vartype shared_private_link_resources: azure.mgmt.search.operations.SharedPrivateLinkResourcesOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.search.operations.UsagesOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The unique identifier for a Microsoft Azure subscription. You can @@ -56,7 +62,7 @@ class SearchManagementClient: # pylint: disable=client-accepts-api-version-keyw :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-09-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -73,7 +79,7 @@ def __init__( self._config = SearchManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -92,6 +98,7 @@ def __init__( self.shared_private_link_resources = SharedPrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. @@ -122,5 +129,5 @@ def __enter__(self) -> "SearchManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details) -> None: + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/_serialization.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/_serialization.py index f17c068e833e..4bae2292227b 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/_serialization.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/_serialization.py @@ -629,7 +629,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -662,8 +662,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) @@ -741,6 +742,8 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None @@ -749,10 +752,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -891,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -903,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -950,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -1271,7 +1281,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1295,7 +1305,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/_vendor.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/_vendor.py index bd0df84f5319..7c69bc1c15b5 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/_vendor.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/_vendor.py @@ -5,10 +5,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast +from abc import ABC +from typing import TYPE_CHECKING from azure.core.pipeline.transport import HttpRequest +from ._configuration import SearchManagementClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import PipelineClient + + from ._serialization import Deserializer, Serializer + def _convert_request(request, files=None): data = request.content if not files else None @@ -18,13 +27,10 @@ def _convert_request(request, files=None): return request -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) +class SearchManagementClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: SearchManagementClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/_version.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/_version.py index b77ac9246082..e5754a47ce68 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/_version.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "9.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_configuration.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_configuration.py index b5ae1b276b46..d813b42ba7e6 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_configuration.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,14 +30,14 @@ class SearchManagementClientConfiguration(Configuration): # pylint: disable=too :param subscription_id: The unique identifier for a Microsoft Azure subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-09-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SearchManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", "2022-09-01") + api_version: str = kwargs.pop("api_version", "2023-11-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_search_management_client.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_search_management_client.py index 5f316590f2a2..ea3e05ccaf32 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_search_management_client.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_search_management_client.py @@ -21,8 +21,10 @@ PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueryKeysOperations, + SearchManagementClientOperationsMixin, ServicesOperations, SharedPrivateLinkResourcesOperations, + UsagesOperations, ) if TYPE_CHECKING: @@ -30,7 +32,9 @@ from azure.core.credentials_async import AsyncTokenCredential -class SearchManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class SearchManagementClient( + SearchManagementClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Client that can be used to manage Azure Cognitive Search services and API keys. :ivar operations: Operations operations @@ -50,6 +54,8 @@ class SearchManagementClient: # pylint: disable=client-accepts-api-version-keyw :ivar shared_private_link_resources: SharedPrivateLinkResourcesOperations operations :vartype shared_private_link_resources: azure.mgmt.search.aio.operations.SharedPrivateLinkResourcesOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.search.aio.operations.UsagesOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The unique identifier for a Microsoft Azure subscription. You can @@ -57,7 +63,7 @@ class SearchManagementClient: # pylint: disable=client-accepts-api-version-keyw :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-09-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -74,7 +80,7 @@ def __init__( self._config = SearchManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -93,6 +99,7 @@ def __init__( self.shared_private_link_resources = SharedPrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. @@ -123,5 +130,5 @@ async def __aenter__(self) -> "SearchManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_vendor.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_vendor.py new file mode 100644 index 000000000000..f66a40025d67 --- /dev/null +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_vendor.py @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import SearchManagementClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import AsyncPipelineClient + + from .._serialization import Deserializer, Serializer + + +class SearchManagementClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: SearchManagementClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/__init__.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/__init__.py index b7967f39c207..b96a319c2e09 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/__init__.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/__init__.py @@ -13,6 +13,8 @@ from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._shared_private_link_resources_operations import SharedPrivateLinkResourcesOperations +from ._usages_operations import UsagesOperations +from ._search_management_client_operations import SearchManagementClientOperationsMixin from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -26,6 +28,8 @@ "PrivateLinkResourcesOperations", "PrivateEndpointConnectionsOperations", "SharedPrivateLinkResourcesOperations", + "UsagesOperations", + "SearchManagementClientOperationsMixin", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_admin_keys_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_admin_keys_operations.py index 17bd173e0489..1ba6cc833801 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_admin_keys_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_admin_keys_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -27,11 +26,8 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._admin_keys_operations import build_get_request, build_regenerate_request +from .._vendor import SearchManagementClientMixinABC -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -65,6 +61,9 @@ async def get( ) -> _models.AdminKeyResult: """Gets the primary and secondary admin API keys for the specified Azure Cognitive Search service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -90,9 +89,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AdminKeyResult] = kwargs.pop("cls", None) _client_request_id = None @@ -112,8 +109,9 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,6 +143,9 @@ async def regenerate( """Regenerates either the primary or secondary admin API key. You can only regenerate one key at a time. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -173,9 +174,7 @@ async def regenerate( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AdminKeyResult] = kwargs.pop("cls", None) _client_request_id = None @@ -196,8 +195,9 @@ async def regenerate( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_operations.py index 59426db1af96..0f732497db2f 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -29,11 +28,8 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request +from .._vendor import SearchManagementClientMixinABC -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,9 +65,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { @@ -122,8 +116,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_endpoint_connections_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_endpoint_connections_operations.py index 56690086adeb..bdef7873d36d 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -35,11 +35,8 @@ build_list_by_service_request, build_update_request, ) +from .._vendor import SearchManagementClientMixinABC -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,6 +74,9 @@ async def update( ) -> _models.PrivateEndpointConnection: """Updates a Private Endpoint connection to the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -115,6 +115,9 @@ async def update( ) -> _models.PrivateEndpointConnection: """Updates a Private Endpoint connection to the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -151,6 +154,9 @@ async def update( ) -> _models.PrivateEndpointConnection: """Updates a Private Endpoint connection to the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -161,7 +167,7 @@ async def update( Azure Cognitive Search service with the specified resource group. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The definition of the private endpoint connection to - update. Is either a model type or a IO type. Required. + update. Is either a PrivateEndpointConnection type or a IO type. Required. :type private_endpoint_connection: ~azure.mgmt.search.models.PrivateEndpointConnection or IO :param search_management_request_options: Parameter group. Default value is None. :type search_management_request_options: @@ -185,9 +191,7 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -197,7 +201,7 @@ async def update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -219,8 +223,9 @@ async def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -252,6 +257,9 @@ async def get( """Gets the details of the private endpoint connection to the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -280,9 +288,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) _client_request_id = None @@ -303,8 +309,9 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -335,6 +342,9 @@ async def delete( ) -> Optional[_models.PrivateEndpointConnection]: """Disconnects the private endpoint connection and deletes it from the search service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -363,9 +373,7 @@ async def delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) _client_request_id = None @@ -386,8 +394,9 @@ async def delete( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -419,6 +428,9 @@ def list_by_service( ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """Gets a list of all private endpoint connections in the given service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -438,9 +450,7 @@ def list_by_service( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { @@ -498,8 +508,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_link_resources_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_link_resources_operations.py index 34b0497a4323..dd1f50169adc 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_link_resources_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -29,11 +28,8 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_supported_request +from .._vendor import SearchManagementClientMixinABC -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,6 +63,9 @@ def list_supported( ) -> AsyncIterable["_models.PrivateLinkResource"]: """Gets a list of all supported private link resource types for the given service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -84,9 +83,7 @@ def list_supported( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResourcesResult] = kwargs.pop("cls", None) error_map = { @@ -144,8 +141,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_query_keys_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_query_keys_operations.py index 1c6a76a45b83..0f55803437d9 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_query_keys_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_query_keys_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -34,11 +33,8 @@ build_delete_request, build_list_by_search_service_request, ) +from .._vendor import SearchManagementClientMixinABC -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,6 +70,9 @@ async def create( """Generates a new query key for the specified search service. You can create up to 50 query keys per service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -101,9 +100,7 @@ async def create( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.QueryKey] = kwargs.pop("cls", None) _client_request_id = None @@ -124,8 +121,9 @@ async def create( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,6 +153,9 @@ def list_by_search_service( ) -> AsyncIterable["_models.QueryKey"]: """Returns the list of query API keys for the given Azure Cognitive Search service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -172,9 +173,7 @@ def list_by_search_service( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListQueryKeysResult] = kwargs.pop("cls", None) error_map = { @@ -232,8 +231,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -261,6 +261,9 @@ async def delete( # pylint: disable=inconsistent-return-statements """Deletes the specified query key. Unlike admin keys, query keys are not regenerated. The process for regenerating a query key is to delete and then recreate it. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -289,9 +292,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) _client_request_id = None @@ -312,8 +313,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_search_management_client_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_search_management_client_operations.py new file mode 100644 index 000000000000..f29b53fc6b0d --- /dev/null +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_search_management_client_operations.py @@ -0,0 +1,113 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._search_management_client_operations import build_usage_by_subscription_sku_request +from .._vendor import SearchManagementClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SearchManagementClientOperationsMixin(SearchManagementClientMixinABC): + @distributed_trace_async + async def usage_by_subscription_sku( + self, + location: str, + sku_name: str, + search_management_request_options: Optional[_models.SearchManagementRequestOptions] = None, + **kwargs: Any + ) -> _models.QuotaUsageResult: + """Gets the quota usage for a search sku in the given subscription. + + .. seealso:: + - https://aka.ms/search-manage + + :param location: The unique location name for a Microsoft Azure geographic region. Required. + :type location: str + :param sku_name: The unique search service sku name supported by Azure Cognitive Search. + Required. + :type sku_name: str + :param search_management_request_options: Parameter group. Default value is None. + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QuotaUsageResult or the result of cls(response) + :rtype: ~azure.mgmt.search.models.QuotaUsageResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.QuotaUsageResult] = kwargs.pop("cls", None) + + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_usage_by_subscription_sku_request( + location=location, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + api_version=api_version, + template_url=self.usage_by_subscription_sku.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("QuotaUsageResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + usage_by_subscription_sku.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Search/locations/{location}/usages/{skuName}" + } diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_services_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_services_operations.py index da2d6969fc55..950034e8b95a 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_services_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_services_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -40,6 +41,7 @@ build_list_by_subscription_request, build_update_request, ) +from .._vendor import SearchManagementClientMixinABC if sys.version_info >= (3, 8): from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports @@ -87,9 +89,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SearchService] = kwargs.pop("cls", None) @@ -99,7 +99,7 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(service, (IO, bytes)): + if isinstance(service, (IOBase, bytes)): _content = service else: _json = self._serialize.body(service, "SearchService") @@ -120,8 +120,9 @@ async def _create_or_update_initial( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -159,6 +160,9 @@ async def begin_create_or_update( """Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -205,6 +209,9 @@ async def begin_create_or_update( """Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -249,6 +256,9 @@ async def begin_create_or_update( """Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -259,8 +269,8 @@ async def begin_create_or_update( of the service URI (https://:code:``.search.windows.net). You cannot change the service name after the service is created. Required. :type search_service_name: str - :param service: The definition of the search service to create or update. Is either a model - type or a IO type. Required. + :param service: The definition of the search service to create or update. Is either a + SearchService type or a IO type. Required. :type service: ~azure.mgmt.search.models.SearchService or IO :param search_management_request_options: Parameter group. Default value is None. :type search_management_request_options: @@ -284,9 +294,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SearchService] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -345,6 +353,9 @@ async def update( ) -> _models.SearchService: """Updates an existing search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -377,6 +388,9 @@ async def update( ) -> _models.SearchService: """Updates an existing search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -407,13 +421,16 @@ async def update( ) -> _models.SearchService: """Updates an existing search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str :param search_service_name: The name of the Azure Cognitive Search service to update. Required. :type search_service_name: str - :param service: The definition of the search service to update. Is either a model type or a IO - type. Required. + :param service: The definition of the search service to update. Is either a SearchServiceUpdate + type or a IO type. Required. :type service: ~azure.mgmt.search.models.SearchServiceUpdate or IO :param search_management_request_options: Parameter group. Default value is None. :type search_management_request_options: @@ -437,9 +454,7 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SearchService] = kwargs.pop("cls", None) @@ -449,7 +464,7 @@ async def update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(service, (IO, bytes)): + if isinstance(service, (IOBase, bytes)): _content = service else: _json = self._serialize.body(service, "SearchServiceUpdate") @@ -470,8 +485,9 @@ async def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -501,6 +517,9 @@ async def get( ) -> _models.SearchService: """Gets the search service with the given name in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -526,9 +545,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SearchService] = kwargs.pop("cls", None) _client_request_id = None @@ -548,8 +565,9 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -579,6 +597,9 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a search service in the given resource group, along with its associated resources. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -604,9 +625,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) _client_request_id = None @@ -626,8 +645,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -652,6 +672,9 @@ def list_by_resource_group( ) -> AsyncIterable["_models.SearchService"]: """Gets a list of all Search services in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -666,9 +689,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SearchServiceListResult] = kwargs.pop("cls", None) error_map = { @@ -725,8 +746,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -748,6 +770,9 @@ def list_by_subscription( ) -> AsyncIterable["_models.SearchService"]: """Gets a list of all Search services in the given subscription. + .. seealso:: + - https://aka.ms/search-manage + :param search_management_request_options: Parameter group. Default value is None. :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions @@ -759,9 +784,7 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SearchServiceListResult] = kwargs.pop("cls", None) error_map = { @@ -817,8 +840,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -843,6 +867,9 @@ async def check_name_availability( must be globally unique since they are part of the service URI (https://:code:``.search.windows.net). + .. seealso:: + - https://aka.ms/search-manage + :param name: The search service name to validate. Search service names must only contain lowercase letters, digits or dashes, cannot use dash as the first two or last one characters, cannot contain consecutive dashes, and must be between 2 and 60 characters in length. Required. @@ -870,9 +897,7 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) type: Literal["searchServices"] = kwargs.pop("type", "searchServices") cls: ClsType[_models.CheckNameAvailabilityOutput] = kwargs.pop("cls", None) @@ -896,8 +921,9 @@ async def check_name_availability( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_shared_private_link_resources_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_shared_private_link_resources_operations.py index e5fc3dc81da5..9e122542e18c 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_shared_private_link_resources_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_shared_private_link_resources_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -37,11 +37,8 @@ build_get_request, build_list_by_service_request, ) +from .._vendor import SearchManagementClientMixinABC -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -85,9 +82,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.SharedPrivateLinkResource]] = kwargs.pop("cls", None) @@ -97,7 +92,7 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(shared_private_link_resource, (IO, bytes)): + if isinstance(shared_private_link_resource, (IOBase, bytes)): _content = shared_private_link_resource else: _json = self._serialize.body(shared_private_link_resource, "SharedPrivateLinkResource") @@ -119,8 +114,9 @@ async def _create_or_update_initial( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -157,6 +153,9 @@ async def begin_create_or_update( """Initiates the creation or update of a shared private link resource managed by the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -204,6 +203,9 @@ async def begin_create_or_update( """Initiates the creation or update of a shared private link resource managed by the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -249,6 +251,9 @@ async def begin_create_or_update( """Initiates the creation or update of a shared private link resource managed by the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -259,7 +264,7 @@ async def begin_create_or_update( by the Azure Cognitive Search service within the specified resource group. Required. :type shared_private_link_resource_name: str :param shared_private_link_resource: The definition of the shared private link resource to - create or update. Is either a model type or a IO type. Required. + create or update. Is either a SharedPrivateLinkResource type or a IO type. Required. :type shared_private_link_resource: ~azure.mgmt.search.models.SharedPrivateLinkResource or IO :param search_management_request_options: Parameter group. Default value is None. :type search_management_request_options: @@ -283,9 +288,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -347,6 +350,9 @@ async def get( """Gets the details of the shared private link resource managed by the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -375,9 +381,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) _client_request_id = None @@ -398,8 +402,9 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -438,9 +443,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) _client_request_id = None @@ -461,8 +464,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -489,6 +493,9 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Initiates the deletion of the shared private link resource from the search service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -516,9 +523,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -573,6 +578,9 @@ def list_by_service( ) -> AsyncIterable["_models.SharedPrivateLinkResource"]: """Gets a list of all shared private link resources managed by the given service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -592,9 +600,7 @@ def list_by_service( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SharedPrivateLinkResourceListResult] = kwargs.pop("cls", None) error_map = { @@ -652,8 +658,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_usages_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_usages_operations.py new file mode 100644 index 000000000000..aef200530ea9 --- /dev/null +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_usages_operations.py @@ -0,0 +1,154 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._usages_operations import build_list_by_subscription_request +from .._vendor import SearchManagementClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.search.aio.SearchManagementClient`'s + :attr:`usages` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription( + self, + location: str, + search_management_request_options: Optional[_models.SearchManagementRequestOptions] = None, + **kwargs: Any + ) -> AsyncIterable["_models.QuotaUsageResult"]: + """Gets a list of all Search quota usages in the given subscription. + + .. seealso:: + - https://aka.ms/search-manage + + :param location: The unique location name for a Microsoft Azure geographic region. Required. + :type location: str + :param search_management_request_options: Parameter group. Default value is None. + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either QuotaUsageResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.search.models.QuotaUsageResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.QuotaUsagesListResult] = kwargs.pop("cls", None) + + error_map = { + 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: + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_subscription_request( + location=location, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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 + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("QuotaUsagesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or 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( # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Search/locations/{location}/usages" + } diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/models/__init__.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/models/__init__.py index 8feb69069db5..414aae883dd0 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/models/__init__.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/models/__init__.py @@ -30,6 +30,9 @@ from ._models_py3 import PrivateLinkResourceProperties from ._models_py3 import PrivateLinkResourcesResult from ._models_py3 import QueryKey +from ._models_py3 import QuotaUsageResult +from ._models_py3 import QuotaUsageResultName +from ._models_py3 import QuotaUsagesListResult from ._models_py3 import Resource from ._models_py3 import SearchManagementRequestOptions from ._models_py3 import SearchService @@ -53,6 +56,7 @@ from ._search_management_client_enums import PublicNetworkAccess from ._search_management_client_enums import SearchEncryptionComplianceStatus from ._search_management_client_enums import SearchEncryptionWithCmk +from ._search_management_client_enums import SearchSemanticSearch from ._search_management_client_enums import SearchServiceStatus from ._search_management_client_enums import SharedPrivateLinkResourceAsyncOperationResult from ._search_management_client_enums import SharedPrivateLinkResourceProvisioningState @@ -88,6 +92,9 @@ "PrivateLinkResourceProperties", "PrivateLinkResourcesResult", "QueryKey", + "QuotaUsageResult", + "QuotaUsageResultName", + "QuotaUsagesListResult", "Resource", "SearchManagementRequestOptions", "SearchService", @@ -110,6 +117,7 @@ "PublicNetworkAccess", "SearchEncryptionComplianceStatus", "SearchEncryptionWithCmk", + "SearchSemanticSearch", "SearchServiceStatus", "SharedPrivateLinkResourceAsyncOperationResult", "SharedPrivateLinkResourceProvisioningState", diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_models_py3.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_models_py3.py index 7e1f8f58f53d..73004cccd71c 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_models_py3.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_models_py3.py @@ -896,6 +896,120 @@ def __init__(self, **kwargs: Any) -> None: self.key = None +class QuotaUsageResult(_serialization.Model): + """Describes the quota usage for a particular sku supported by Azure Cognitive Search. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource id of the quota usage sku endpoint for Microsoft.Search provider. + :vartype id: str + :ivar unit: The unit of measurement for the search sku. + :vartype unit: str + :ivar current_value: The currently used up value for the particular search sku. + :vartype current_value: int + :ivar limit: The quota limit for the particular search sku. + :vartype limit: int + :ivar name: The name of the sku supported by Azure Cognitive Search. + :vartype name: ~azure.mgmt.search.models.QuotaUsageResultName + """ + + _validation = { + "name": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "QuotaUsageResultName"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + unit: Optional[str] = None, + current_value: Optional[int] = None, + limit: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The resource id of the quota usage sku endpoint for Microsoft.Search provider. + :paramtype id: str + :keyword unit: The unit of measurement for the search sku. + :paramtype unit: str + :keyword current_value: The currently used up value for the particular search sku. + :paramtype current_value: int + :keyword limit: The quota limit for the particular search sku. + :paramtype limit: int + """ + super().__init__(**kwargs) + self.id = id + self.unit = unit + self.current_value = current_value + self.limit = limit + self.name = None + + +class QuotaUsageResultName(_serialization.Model): + """The name of the sku supported by Azure Cognitive Search. + + :ivar value: The sku name supported by Azure Cognitive Search. + :vartype value: str + :ivar localized_value: The localized string value for the sku supported by Azure Cognitive + Search. + :vartype localized_value: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, + } + + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The sku name supported by Azure Cognitive Search. + :paramtype value: str + :keyword localized_value: The localized string value for the sku supported by Azure Cognitive + Search. + :paramtype localized_value: str + """ + super().__init__(**kwargs) + self.value = value + self.localized_value = localized_value + + +class QuotaUsagesListResult(_serialization.Model): + """Response containing the quota usage information for all the supported skus of Azure Cognitive + Search service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The quota usages for the SKUs supported by Azure Cognitive Search. + :vartype value: list[~azure.mgmt.search.models.QuotaUsageResult] + :ivar next_link: Request URL that can be used to query next page of quota usages. Returned when + the total number of requested quota usages exceed maximum page size. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[QuotaUsageResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + class SearchManagementRequestOptions(_serialization.Model): """Parameter group. @@ -1019,7 +1133,7 @@ class SearchService(TrackedResource): # pylint: disable=too-many-instance-attri state. If your service is in the degraded, disabled, or error states, it means the Azure Cognitive Search team is actively investigating the underlying issue. Dedicated services in these states are still chargeable based on the number of search units provisioned. Known values - are: "running", "provisioning", "deleting", "degraded", "disabled", "error", and "stopped". + are: "running", "provisioning", "deleting", "degraded", "disabled", and "error". :vartype status: str or ~azure.mgmt.search.models.SearchServiceStatus :ivar status_details: The details of the search service status. :vartype status_details: str @@ -1050,6 +1164,10 @@ class SearchService(TrackedResource): # pylint: disable=too-many-instance-attri Cognitive Search service. :vartype private_endpoint_connections: list[~azure.mgmt.search.models.PrivateEndpointConnection] + :ivar semantic_search: Sets options that control the availability of semantic search. This + configuration is only possible for certain Azure Cognitive Search SKUs in certain locations. + Known values are: "disabled", "free", and "standard". + :vartype semantic_search: str or ~azure.mgmt.search.models.SearchSemanticSearch :ivar shared_private_link_resources: The list of shared private link resources managed by the Azure Cognitive Search service. :vartype shared_private_link_resources: @@ -1093,6 +1211,7 @@ class SearchService(TrackedResource): # pylint: disable=too-many-instance-attri "key": "properties.privateEndpointConnections", "type": "[PrivateEndpointConnection]", }, + "semantic_search": {"key": "properties.semanticSearch", "type": "str"}, "shared_private_link_resources": { "key": "properties.sharedPrivateLinkResources", "type": "[SharedPrivateLinkResource]", @@ -1114,6 +1233,7 @@ def __init__( encryption_with_cmk: Optional["_models.EncryptionWithCmk"] = None, disable_local_auth: Optional[bool] = None, auth_options: Optional["_models.DataPlaneAuthOptions"] = None, + semantic_search: Optional[Union[str, "_models.SearchSemanticSearch"]] = None, **kwargs: Any ) -> None: """ @@ -1159,6 +1279,10 @@ def __init__( :keyword auth_options: Defines the options for how the data plane API of a search service authenticates requests. This cannot be set if 'disableLocalAuth' is set to true. :paramtype auth_options: ~azure.mgmt.search.models.DataPlaneAuthOptions + :keyword semantic_search: Sets options that control the availability of semantic search. This + configuration is only possible for certain Azure Cognitive Search SKUs in certain locations. + Known values are: "disabled", "free", and "standard". + :paramtype semantic_search: str or ~azure.mgmt.search.models.SearchSemanticSearch """ super().__init__(tags=tags, location=location, **kwargs) self.sku = sku @@ -1175,6 +1299,7 @@ def __init__( self.disable_local_auth = disable_local_auth self.auth_options = auth_options self.private_endpoint_connections = None + self.semantic_search = semantic_search self.shared_private_link_resources = None @@ -1259,7 +1384,7 @@ class SearchServiceUpdate(Resource): # pylint: disable=too-many-instance-attrib state. If your service is in the degraded, disabled, or error states, it means the Azure Cognitive Search team is actively investigating the underlying issue. Dedicated services in these states are still chargeable based on the number of search units provisioned. Known values - are: "running", "provisioning", "deleting", "degraded", "disabled", "error", and "stopped". + are: "running", "provisioning", "deleting", "degraded", "disabled", and "error". :vartype status: str or ~azure.mgmt.search.models.SearchServiceStatus :ivar status_details: The details of the search service status. :vartype status_details: str @@ -1290,6 +1415,10 @@ class SearchServiceUpdate(Resource): # pylint: disable=too-many-instance-attrib Cognitive Search service. :vartype private_endpoint_connections: list[~azure.mgmt.search.models.PrivateEndpointConnection] + :ivar semantic_search: Sets options that control the availability of semantic search. This + configuration is only possible for certain Azure Cognitive Search SKUs in certain locations. + Known values are: "disabled", "free", and "standard". + :vartype semantic_search: str or ~azure.mgmt.search.models.SearchSemanticSearch :ivar shared_private_link_resources: The list of shared private link resources managed by the Azure Cognitive Search service. :vartype shared_private_link_resources: @@ -1332,6 +1461,7 @@ class SearchServiceUpdate(Resource): # pylint: disable=too-many-instance-attrib "key": "properties.privateEndpointConnections", "type": "[PrivateEndpointConnection]", }, + "semantic_search": {"key": "properties.semanticSearch", "type": "str"}, "shared_private_link_resources": { "key": "properties.sharedPrivateLinkResources", "type": "[SharedPrivateLinkResource]", @@ -1353,6 +1483,7 @@ def __init__( encryption_with_cmk: Optional["_models.EncryptionWithCmk"] = None, disable_local_auth: Optional[bool] = None, auth_options: Optional["_models.DataPlaneAuthOptions"] = None, + semantic_search: Optional[Union[str, "_models.SearchSemanticSearch"]] = None, **kwargs: Any ) -> None: """ @@ -1400,6 +1531,10 @@ def __init__( :keyword auth_options: Defines the options for how the data plane API of a search service authenticates requests. This cannot be set if 'disableLocalAuth' is set to true. :paramtype auth_options: ~azure.mgmt.search.models.DataPlaneAuthOptions + :keyword semantic_search: Sets options that control the availability of semantic search. This + configuration is only possible for certain Azure Cognitive Search SKUs in certain locations. + Known values are: "disabled", "free", and "standard". + :paramtype semantic_search: str or ~azure.mgmt.search.models.SearchSemanticSearch """ super().__init__(**kwargs) self.sku = sku @@ -1418,6 +1553,7 @@ def __init__( self.disable_local_auth = disable_local_auth self.auth_options = auth_options self.private_endpoint_connections = None + self.semantic_search = semantic_search self.shared_private_link_resources = None diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_search_management_client_enums.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_search_management_client_enums.py index 991db6160eec..4b592680bca0 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_search_management_client_enums.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/models/_search_management_client_enums.py @@ -144,6 +144,22 @@ class SearchEncryptionWithCmk(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: set to 'Disabled'.""" +class SearchSemanticSearch(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Sets options that control the availability of semantic search. This configuration is only + possible for certain Azure Cognitive Search SKUs in certain locations. + """ + + DISABLED = "disabled" + """Indicates that semantic search is disabled for the search service.""" + FREE = "free" + """Enables semantic search on a search service and indicates that it is to be used within the + #: limits of the free tier. This would cap the volume of semantic search requests and is offered + #: at no extra charge. This is the default for newly provisioned search services.""" + STANDARD = "standard" + """Enables semantic search on a search service as a billable feature, with higher throughput and + #: volume of semantic search queries.""" + + class SearchServiceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the search service. Possible values include: 'running': The search service is running and no provisioning operations are underway. 'provisioning': The search service is @@ -170,8 +186,6 @@ class SearchServiceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): ERROR = "error" """The search service is in error state, indicating either a failure to provision or to be #: deleted.""" - STOPPED = "stopped" - """The search service is in a subscription that's disabled.""" class SharedPrivateLinkResourceAsyncOperationResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/__init__.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/__init__.py index b7967f39c207..b96a319c2e09 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/__init__.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/__init__.py @@ -13,6 +13,8 @@ from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._shared_private_link_resources_operations import SharedPrivateLinkResourcesOperations +from ._usages_operations import UsagesOperations +from ._search_management_client_operations import SearchManagementClientOperationsMixin from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -26,6 +28,8 @@ "PrivateLinkResourcesOperations", "PrivateEndpointConnectionsOperations", "SharedPrivateLinkResourcesOperations", + "UsagesOperations", + "SearchManagementClientOperationsMixin", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_admin_keys_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_admin_keys_operations.py index 3af98f16d85a..3685b1476585 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_admin_keys_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_admin_keys_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import SearchManagementClientMixinABC, _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +45,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +59,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,7 +84,7 @@ def build_regenerate_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -104,7 +99,7 @@ def build_regenerate_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -146,6 +141,9 @@ def get( ) -> _models.AdminKeyResult: """Gets the primary and secondary admin API keys for the specified Azure Cognitive Search service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -171,9 +169,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AdminKeyResult] = kwargs.pop("cls", None) _client_request_id = None @@ -193,8 +189,9 @@ def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -226,6 +223,9 @@ def regenerate( """Regenerates either the primary or secondary admin API key. You can only regenerate one key at a time. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -254,9 +254,7 @@ def regenerate( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AdminKeyResult] = kwargs.pop("cls", None) _client_request_id = None @@ -277,8 +275,9 @@ def regenerate( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_operations.py index 0db127672e2a..72f79afe75d9 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -28,12 +27,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +from .._vendor import SearchManagementClientMixinABC, _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,9 +86,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { @@ -144,8 +137,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_endpoint_connections_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_endpoint_connections_operations.py index b935d3cc8fad..ddb7dfec8c20 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_endpoint_connections_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -28,12 +28,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import SearchManagementClientMixinABC, _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +49,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -71,7 +67,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,7 +94,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -115,7 +111,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -140,7 +136,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -157,7 +153,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -181,7 +177,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -195,7 +191,7 @@ def build_list_by_service_request( "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -241,6 +237,9 @@ def update( ) -> _models.PrivateEndpointConnection: """Updates a Private Endpoint connection to the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -279,6 +278,9 @@ def update( ) -> _models.PrivateEndpointConnection: """Updates a Private Endpoint connection to the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -315,6 +317,9 @@ def update( ) -> _models.PrivateEndpointConnection: """Updates a Private Endpoint connection to the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -325,7 +330,7 @@ def update( Azure Cognitive Search service with the specified resource group. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The definition of the private endpoint connection to - update. Is either a model type or a IO type. Required. + update. Is either a PrivateEndpointConnection type or a IO type. Required. :type private_endpoint_connection: ~azure.mgmt.search.models.PrivateEndpointConnection or IO :param search_management_request_options: Parameter group. Default value is None. :type search_management_request_options: @@ -349,9 +354,7 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -361,7 +364,7 @@ def update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -383,8 +386,9 @@ def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -416,6 +420,9 @@ def get( """Gets the details of the private endpoint connection to the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -444,9 +451,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) _client_request_id = None @@ -467,8 +472,9 @@ def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -499,6 +505,9 @@ def delete( ) -> Optional[_models.PrivateEndpointConnection]: """Disconnects the private endpoint connection and deletes it from the search service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -527,9 +536,7 @@ def delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) _client_request_id = None @@ -550,8 +557,9 @@ def delete( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -583,6 +591,9 @@ def list_by_service( ) -> Iterable["_models.PrivateEndpointConnection"]: """Gets a list of all private endpoint connections in the given service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -601,9 +612,7 @@ def list_by_service( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { @@ -661,8 +670,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_link_resources_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_link_resources_operations.py index ab8eaeaa4281..36e82e4fd989 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_link_resources_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -28,12 +27,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import SearchManagementClientMixinABC, _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +47,7 @@ def build_list_supported_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +61,7 @@ def build_list_supported_request( "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -108,6 +103,9 @@ def list_supported( ) -> Iterable["_models.PrivateLinkResource"]: """Gets a list of all supported private link resource types for the given service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -125,9 +123,7 @@ def list_supported( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResourcesResult] = kwargs.pop("cls", None) error_map = { @@ -185,8 +181,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_query_keys_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_query_keys_operations.py index cf19c6af0e6f..72f9c436280a 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_query_keys_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_query_keys_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -28,12 +27,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import SearchManagementClientMixinABC, _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +48,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +63,7 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,7 +87,7 @@ def build_list_by_search_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,7 +101,7 @@ def build_list_by_search_service_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -131,7 +126,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -146,7 +141,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -190,6 +185,9 @@ def create( """Generates a new query key for the specified search service. You can create up to 50 query keys per service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -217,9 +215,7 @@ def create( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.QueryKey] = kwargs.pop("cls", None) _client_request_id = None @@ -240,8 +236,9 @@ def create( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -271,6 +268,9 @@ def list_by_search_service( ) -> Iterable["_models.QueryKey"]: """Returns the list of query API keys for the given Azure Cognitive Search service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -288,9 +288,7 @@ def list_by_search_service( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListQueryKeysResult] = kwargs.pop("cls", None) error_map = { @@ -348,8 +346,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -377,6 +376,9 @@ def delete( # pylint: disable=inconsistent-return-statements """Deletes the specified query key. Unlike admin keys, query keys are not regenerated. The process for regenerating a query key is to delete and then recreate it. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -405,9 +407,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) _client_request_id = None @@ -428,8 +428,9 @@ def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_search_management_client_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_search_management_client_operations.py new file mode 100644 index 000000000000..79f48eba960b --- /dev/null +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_search_management_client_operations.py @@ -0,0 +1,148 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import SearchManagementClientMixinABC, _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_usage_by_subscription_sku_request( + location: str, sku_name: str, subscription_id: str, *, client_request_id: Optional[str] = None, **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", "2023-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Search/locations/{location}/usages/{skuName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "skuName": _SERIALIZER.url("sku_name", sku_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if client_request_id is not None: + _headers["x-ms-client-request-id"] = _SERIALIZER.header("client_request_id", client_request_id, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SearchManagementClientOperationsMixin(SearchManagementClientMixinABC): + @distributed_trace + def usage_by_subscription_sku( + self, + location: str, + sku_name: str, + search_management_request_options: Optional[_models.SearchManagementRequestOptions] = None, + **kwargs: Any + ) -> _models.QuotaUsageResult: + """Gets the quota usage for a search sku in the given subscription. + + .. seealso:: + - https://aka.ms/search-manage + + :param location: The unique location name for a Microsoft Azure geographic region. Required. + :type location: str + :param sku_name: The unique search service sku name supported by Azure Cognitive Search. + Required. + :type sku_name: str + :param search_management_request_options: Parameter group. Default value is None. + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QuotaUsageResult or the result of cls(response) + :rtype: ~azure.mgmt.search.models.QuotaUsageResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.QuotaUsageResult] = kwargs.pop("cls", None) + + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_usage_by_subscription_sku_request( + location=location, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + api_version=api_version, + template_url=self.usage_by_subscription_sku.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("QuotaUsageResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + usage_by_subscription_sku.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Search/locations/{location}/usages/{skuName}" + } diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_services_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_services_operations.py index cc4f88938792..60f6fd31a764 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_services_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_services_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,7 +31,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import SearchManagementClientMixinABC, _convert_request if sys.version_info >= (3, 8): from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports @@ -54,7 +55,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -69,7 +70,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,7 +96,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -110,7 +111,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -136,7 +137,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -150,7 +151,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -174,7 +175,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,7 +189,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -207,7 +208,7 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -220,7 +221,7 @@ def build_list_by_resource_group_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -239,7 +240,7 @@ def build_list_by_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -248,7 +249,7 @@ def build_list_by_subscription_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -267,7 +268,7 @@ def build_check_name_availability_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") type = "searchServices" @@ -280,7 +281,7 @@ def build_check_name_availability_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -333,9 +334,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SearchService] = kwargs.pop("cls", None) @@ -345,7 +344,7 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(service, (IO, bytes)): + if isinstance(service, (IOBase, bytes)): _content = service else: _json = self._serialize.body(service, "SearchService") @@ -366,8 +365,9 @@ def _create_or_update_initial( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -405,6 +405,9 @@ def begin_create_or_update( """Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -451,6 +454,9 @@ def begin_create_or_update( """Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -495,6 +501,9 @@ def begin_create_or_update( """Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -505,8 +514,8 @@ def begin_create_or_update( of the service URI (https://:code:``.search.windows.net). You cannot change the service name after the service is created. Required. :type search_service_name: str - :param service: The definition of the search service to create or update. Is either a model - type or a IO type. Required. + :param service: The definition of the search service to create or update. Is either a + SearchService type or a IO type. Required. :type service: ~azure.mgmt.search.models.SearchService or IO :param search_management_request_options: Parameter group. Default value is None. :type search_management_request_options: @@ -530,9 +539,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SearchService] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -591,6 +598,9 @@ def update( ) -> _models.SearchService: """Updates an existing search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -623,6 +633,9 @@ def update( ) -> _models.SearchService: """Updates an existing search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -653,13 +666,16 @@ def update( ) -> _models.SearchService: """Updates an existing search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str :param search_service_name: The name of the Azure Cognitive Search service to update. Required. :type search_service_name: str - :param service: The definition of the search service to update. Is either a model type or a IO - type. Required. + :param service: The definition of the search service to update. Is either a SearchServiceUpdate + type or a IO type. Required. :type service: ~azure.mgmt.search.models.SearchServiceUpdate or IO :param search_management_request_options: Parameter group. Default value is None. :type search_management_request_options: @@ -683,9 +699,7 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SearchService] = kwargs.pop("cls", None) @@ -695,7 +709,7 @@ def update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(service, (IO, bytes)): + if isinstance(service, (IOBase, bytes)): _content = service else: _json = self._serialize.body(service, "SearchServiceUpdate") @@ -716,8 +730,9 @@ def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -747,6 +762,9 @@ def get( ) -> _models.SearchService: """Gets the search service with the given name in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -772,9 +790,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SearchService] = kwargs.pop("cls", None) _client_request_id = None @@ -794,8 +810,9 @@ def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -825,6 +842,9 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a search service in the given resource group, along with its associated resources. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -850,9 +870,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) _client_request_id = None @@ -872,8 +890,9 @@ def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -898,6 +917,9 @@ def list_by_resource_group( ) -> Iterable["_models.SearchService"]: """Gets a list of all Search services in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -912,9 +934,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SearchServiceListResult] = kwargs.pop("cls", None) error_map = { @@ -971,8 +991,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -994,6 +1015,9 @@ def list_by_subscription( ) -> Iterable["_models.SearchService"]: """Gets a list of all Search services in the given subscription. + .. seealso:: + - https://aka.ms/search-manage + :param search_management_request_options: Parameter group. Default value is None. :type search_management_request_options: ~azure.mgmt.search.models.SearchManagementRequestOptions @@ -1005,9 +1029,7 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SearchServiceListResult] = kwargs.pop("cls", None) error_map = { @@ -1063,8 +1085,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1089,6 +1112,9 @@ def check_name_availability( must be globally unique since they are part of the service URI (https://:code:``.search.windows.net). + .. seealso:: + - https://aka.ms/search-manage + :param name: The search service name to validate. Search service names must only contain lowercase letters, digits or dashes, cannot use dash as the first two or last one characters, cannot contain consecutive dashes, and must be between 2 and 60 characters in length. Required. @@ -1116,9 +1142,7 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) type: Literal["searchServices"] = kwargs.pop("type", "searchServices") cls: ClsType[_models.CheckNameAvailabilityOutput] = kwargs.pop("cls", None) @@ -1142,8 +1166,9 @@ def check_name_availability( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_shared_private_link_resources_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_shared_private_link_resources_operations.py index fd9dad1cbe97..055cdd6ff6c6 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_shared_private_link_resources_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_shared_private_link_resources_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import SearchManagementClientMixinABC, _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +51,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -73,7 +69,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -100,7 +96,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +113,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -142,7 +138,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -159,7 +155,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -183,7 +179,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -197,7 +193,7 @@ def build_list_by_service_request( "searchServiceName": _SERIALIZER.url("search_service_name", search_service_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -249,9 +245,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.SharedPrivateLinkResource]] = kwargs.pop("cls", None) @@ -261,7 +255,7 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(shared_private_link_resource, (IO, bytes)): + if isinstance(shared_private_link_resource, (IOBase, bytes)): _content = shared_private_link_resource else: _json = self._serialize.body(shared_private_link_resource, "SharedPrivateLinkResource") @@ -283,8 +277,9 @@ def _create_or_update_initial( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -321,6 +316,9 @@ def begin_create_or_update( """Initiates the creation or update of a shared private link resource managed by the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -368,6 +366,9 @@ def begin_create_or_update( """Initiates the creation or update of a shared private link resource managed by the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -413,6 +414,9 @@ def begin_create_or_update( """Initiates the creation or update of a shared private link resource managed by the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -423,7 +427,7 @@ def begin_create_or_update( by the Azure Cognitive Search service within the specified resource group. Required. :type shared_private_link_resource_name: str :param shared_private_link_resource: The definition of the shared private link resource to - create or update. Is either a model type or a IO type. Required. + create or update. Is either a SharedPrivateLinkResource type or a IO type. Required. :type shared_private_link_resource: ~azure.mgmt.search.models.SharedPrivateLinkResource or IO :param search_management_request_options: Parameter group. Default value is None. :type search_management_request_options: @@ -447,9 +451,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -510,6 +512,9 @@ def get( """Gets the details of the shared private link resource managed by the search service in the given resource group. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -538,9 +543,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) _client_request_id = None @@ -561,8 +564,9 @@ def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,9 +605,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) _client_request_id = None @@ -624,8 +626,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -652,6 +655,9 @@ def begin_delete( ) -> LROPoller[None]: """Initiates the deletion of the shared private link resource from the search service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -679,9 +685,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -735,6 +739,9 @@ def list_by_service( ) -> Iterable["_models.SharedPrivateLinkResource"]: """Gets a list of all shared private link resources managed by the given service. + .. seealso:: + - https://aka.ms/search-manage + :param resource_group_name: The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str @@ -753,9 +760,7 @@ def list_by_service( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SharedPrivateLinkResourceListResult] = kwargs.pop("cls", None) error_map = { @@ -813,8 +818,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_usages_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_usages_operations.py new file mode 100644 index 000000000000..b0e2b806ce51 --- /dev/null +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_usages_operations.py @@ -0,0 +1,187 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import SearchManagementClientMixinABC, _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request( + location: str, subscription_id: str, *, client_request_id: Optional[str] = None, **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", "2023-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Search/locations/{location}/usages" + ) # pylint: disable=line-too-long + path_format_arguments = { + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if client_request_id is not None: + _headers["x-ms-client-request-id"] = _SERIALIZER.header("client_request_id", client_request_id, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.search.SearchManagementClient`'s + :attr:`usages` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription( + self, + location: str, + search_management_request_options: Optional[_models.SearchManagementRequestOptions] = None, + **kwargs: Any + ) -> Iterable["_models.QuotaUsageResult"]: + """Gets a list of all Search quota usages in the given subscription. + + .. seealso:: + - https://aka.ms/search-manage + + :param location: The unique location name for a Microsoft Azure geographic region. Required. + :type location: str + :param search_management_request_options: Parameter group. Default value is None. + :type search_management_request_options: + ~azure.mgmt.search.models.SearchManagementRequestOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either QuotaUsageResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.search.models.QuotaUsageResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.QuotaUsagesListResult] = kwargs.pop("cls", None) + + error_map = { + 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: + _client_request_id = None + if search_management_request_options is not None: + _client_request_id = search_management_request_options.client_request_id + + request = build_list_by_subscription_request( + location=location, + subscription_id=self._config.subscription_id, + client_request_id=_client_request_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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 + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("QuotaUsagesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Search/locations/{location}/usages" + } diff --git a/sdk/search/azure-mgmt-search/generated_samples/create_or_update_shared_private_link_resource.py b/sdk/search/azure-mgmt-search/generated_samples/create_or_update_shared_private_link_resource.py index f84dbc7b23c6..7298755a0ac9 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/create_or_update_shared_private_link_resource.py +++ b/sdk/search/azure-mgmt-search/generated_samples/create_or_update_shared_private_link_resource.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/CreateOrUpdateSharedPrivateLinkResource.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/CreateOrUpdateSharedPrivateLinkResource.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/delete_private_endpoint_connection.py b/sdk/search/azure-mgmt-search/generated_samples/delete_private_endpoint_connection.py index 1703b4283f9c..7b6945573f10 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/delete_private_endpoint_connection.py +++ b/sdk/search/azure-mgmt-search/generated_samples/delete_private_endpoint_connection.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/DeletePrivateEndpointConnection.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/DeletePrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/delete_shared_private_link_resource.py b/sdk/search/azure-mgmt-search/generated_samples/delete_shared_private_link_resource.py index eb4c99f14469..a1f6ab624043 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/delete_shared_private_link_resource.py +++ b/sdk/search/azure-mgmt-search/generated_samples/delete_shared_private_link_resource.py @@ -29,14 +29,13 @@ def main(): subscription_id="subid", ) - response = client.shared_private_link_resources.begin_delete( + client.shared_private_link_resources.begin_delete( resource_group_name="rg1", search_service_name="mysearchservice", shared_private_link_resource_name="testResource", ).result() - print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/DeleteSharedPrivateLinkResource.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/DeleteSharedPrivateLinkResource.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/get_private_endpoint_connection.py b/sdk/search/azure-mgmt-search/generated_samples/get_private_endpoint_connection.py index 00905fc23153..7cc043d22e66 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/get_private_endpoint_connection.py +++ b/sdk/search/azure-mgmt-search/generated_samples/get_private_endpoint_connection.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/GetPrivateEndpointConnection.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/GetPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/get_quota_usage.py b/sdk/search/azure-mgmt-search/generated_samples/get_quota_usage.py new file mode 100644 index 000000000000..15079a96fbc8 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_samples/get_quota_usage.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.search import SearchManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-search +# USAGE + python get_quota_usage.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SearchManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.usage_by_subscription_sku( + location="westus", + sku_name="free", + ) + print(response) + + +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/GetQuotaUsage.json +if __name__ == "__main__": + main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/get_quota_usages_list.py b/sdk/search/azure-mgmt-search/generated_samples/get_quota_usages_list.py new file mode 100644 index 000000000000..badc450e1f16 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_samples/get_quota_usages_list.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.search import SearchManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-search +# USAGE + python get_quota_usages_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SearchManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.usages.list_by_subscription( + location="westus", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/GetQuotaUsagesList.json +if __name__ == "__main__": + main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/get_shared_private_link_resource.py b/sdk/search/azure-mgmt-search/generated_samples/get_shared_private_link_resource.py index f9fb209d9292..8cb5e8c447f6 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/get_shared_private_link_resource.py +++ b/sdk/search/azure-mgmt-search/generated_samples/get_shared_private_link_resource.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/GetSharedPrivateLinkResource.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/GetSharedPrivateLinkResource.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/list_private_endpoint_connections_by_service.py b/sdk/search/azure-mgmt-search/generated_samples/list_private_endpoint_connections_by_service.py index f0a40c5bfba7..2490eaa9fad7 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/list_private_endpoint_connections_by_service.py +++ b/sdk/search/azure-mgmt-search/generated_samples/list_private_endpoint_connections_by_service.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/ListPrivateEndpointConnectionsByService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/ListPrivateEndpointConnectionsByService.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/list_shared_private_link_resources_by_service.py b/sdk/search/azure-mgmt-search/generated_samples/list_shared_private_link_resources_by_service.py index 3d5cb425a597..f1e4005ab2ae 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/list_shared_private_link_resources_by_service.py +++ b/sdk/search/azure-mgmt-search/generated_samples/list_shared_private_link_resources_by_service.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/ListSharedPrivateLinkResourcesByService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/ListSharedPrivateLinkResourcesByService.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/list_supported_private_link_resources.py b/sdk/search/azure-mgmt-search/generated_samples/list_supported_private_link_resources.py index 1d0025e3a9de..9fb370e9bfb1 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/list_supported_private_link_resources.py +++ b/sdk/search/azure-mgmt-search/generated_samples/list_supported_private_link_resources.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/ListSupportedPrivateLinkResources.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/ListSupportedPrivateLinkResources.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/operations_list.py b/sdk/search/azure-mgmt-search/generated_samples/operations_list.py index 824242e1cfc3..46decc33c902 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/operations_list.py +++ b/sdk/search/azure-mgmt-search/generated_samples/operations_list.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/OperationsList.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/OperationsList.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service.py b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service.py index e3599986c349..9e075e6442cd 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service.py @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchCreateOrUpdateService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchCreateOrUpdateService.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_auth_options.py b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_auth_options.py index 0862edaca7d8..e4ccf0282155 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_auth_options.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_auth_options.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchCreateOrUpdateServiceAuthOptions.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchCreateOrUpdateServiceAuthOptions.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_disable_local_auth.py b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_disable_local_auth.py index d00cee29931b..501642741a82 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_disable_local_auth.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_disable_local_auth.py @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchCreateOrUpdateServiceDisableLocalAuth.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchCreateOrUpdateServiceDisableLocalAuth.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_to_allow_access_from_private_endpoints.py b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_to_allow_access_from_private_endpoints.py index 2f9941264396..3d8052de2742 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_to_allow_access_from_private_endpoints.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_to_allow_access_from_private_endpoints.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPrivateEndpoints.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPrivateEndpoints.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_to_allow_access_from_public_custom_ips.py b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_to_allow_access_from_public_custom_ips.py index ca81bd351079..2d43e1c57126 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_to_allow_access_from_public_custom_ips.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_to_allow_access_from_public_custom_ips.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPs.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPs.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_with_cmk_enforcement.py b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_with_cmk_enforcement.py index df9e485e9c49..683844a47c55 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_with_cmk_enforcement.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_with_cmk_enforcement.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchCreateOrUpdateServiceWithCmkEnforcement.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchCreateOrUpdateServiceWithCmkEnforcement.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_with_identity.py b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_with_identity.py index b3fb30cf4fec..aa3ccd3bd68b 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_with_identity.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_with_identity.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchCreateOrUpdateServiceWithIdentity.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchCreateOrUpdateServiceWithIdentity.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_with_semantic_search.py b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_with_semantic_search.py new file mode 100644 index 000000000000..5cbede35b9c2 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_with_semantic_search.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.search import SearchManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-search +# USAGE + python search_create_or_update_with_semantic_search.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SearchManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.services.begin_create_or_update( + resource_group_name="rg1", + search_service_name="mysearchservice", + service={ + "location": "westus", + "properties": {"hostingMode": "default", "partitionCount": 1, "replicaCount": 3, "semanticSearch": "free"}, + "sku": {"name": "standard"}, + "tags": {"app-name": "My e-commerce app"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchCreateOrUpdateWithSemanticSearch.json +if __name__ == "__main__": + main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_create_query_key.py b/sdk/search/azure-mgmt-search/generated_samples/search_create_query_key.py index 69beedfff28a..2725bc49acbc 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_create_query_key.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_create_query_key.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchCreateQueryKey.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchCreateQueryKey.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_delete_query_key.py b/sdk/search/azure-mgmt-search/generated_samples/search_delete_query_key.py index 73fe4287a18c..4cf27d14d17f 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_delete_query_key.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_delete_query_key.py @@ -29,14 +29,13 @@ def main(): subscription_id="subid", ) - response = client.query_keys.delete( + client.query_keys.delete( resource_group_name="rg1", search_service_name="mysearchservice", key="", ) - print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchDeleteQueryKey.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchDeleteQueryKey.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_delete_service.py b/sdk/search/azure-mgmt-search/generated_samples/search_delete_service.py index 0dcfa2cbe1d6..7dc1bbcf9101 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_delete_service.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_delete_service.py @@ -29,13 +29,12 @@ def main(): subscription_id="subid", ) - response = client.services.delete( + client.services.delete( resource_group_name="rg1", search_service_name="mysearchservice", ) - print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchDeleteService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchDeleteService.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_get_admin_keys.py b/sdk/search/azure-mgmt-search/generated_samples/search_get_admin_keys.py index 7db1238bd873..d32bc1bc0a14 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_get_admin_keys.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_get_admin_keys.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchGetAdminKeys.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchGetAdminKeys.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_get_service.py b/sdk/search/azure-mgmt-search/generated_samples/search_get_service.py index 09df6af3aa06..23e214d9765f 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_get_service.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_get_service.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchGetService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchGetService.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_list_query_keys_by_search_service.py b/sdk/search/azure-mgmt-search/generated_samples/search_list_query_keys_by_search_service.py index fc8f51bc709c..e1f8ab277e8e 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_list_query_keys_by_search_service.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_list_query_keys_by_search_service.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchListQueryKeysBySearchService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchListQueryKeysBySearchService.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_list_services_by_resource_group.py b/sdk/search/azure-mgmt-search/generated_samples/search_list_services_by_resource_group.py index 0ada50f806a2..9e8d478a3e3c 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_list_services_by_resource_group.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_list_services_by_resource_group.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchListServicesByResourceGroup.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchListServicesByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_list_services_by_subscription.py b/sdk/search/azure-mgmt-search/generated_samples/search_list_services_by_subscription.py index d9b85d8beb45..858f87f49446 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_list_services_by_subscription.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_list_services_by_subscription.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchListServicesBySubscription.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchListServicesBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_regenerate_admin_key.py b/sdk/search/azure-mgmt-search/generated_samples/search_regenerate_admin_key.py index 0f33a958c13f..2fefdf1e05ac 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_regenerate_admin_key.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_regenerate_admin_key.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchRegenerateAdminKey.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchRegenerateAdminKey.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_update_service.py b/sdk/search/azure-mgmt-search/generated_samples/search_update_service.py index 6e377951241c..a3d80d8a7079 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_update_service.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_update_service.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchUpdateService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchUpdateService.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_auth_options.py b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_auth_options.py index cefac91e76d2..7b8d9bdbbb9e 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_auth_options.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_auth_options.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchUpdateServiceAuthOptions.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchUpdateServiceAuthOptions.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_disable_local_auth.py b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_disable_local_auth.py index 880e0e707bf4..c500cb2d3897 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_disable_local_auth.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_disable_local_auth.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchUpdateServiceDisableLocalAuth.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchUpdateServiceDisableLocalAuth.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_allow_access_from_private_endpoints.py b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_allow_access_from_private_endpoints.py index 1d095150ca08..fda3eb500b64 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_allow_access_from_private_endpoints.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_allow_access_from_private_endpoints.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchUpdateServiceToAllowAccessFromPrivateEndpoints.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchUpdateServiceToAllowAccessFromPrivateEndpoints.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_allow_access_from_public_custom_ips.py b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_allow_access_from_public_custom_ips.py index a1c03d02847b..7a435705ff25 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_allow_access_from_public_custom_ips.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_allow_access_from_public_custom_ips.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchUpdateServiceToAllowAccessFromPublicCustomIPs.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchUpdateServiceToAllowAccessFromPublicCustomIPs.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_remove_identity.py b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_remove_identity.py index 2547cdd49c40..ed361bcfb2ff 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_remove_identity.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_remove_identity.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchUpdateServiceToRemoveIdentity.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchUpdateServiceToRemoveIdentity.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_with_cmk_enforcement.py b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_with_cmk_enforcement.py index 720191edab95..708deb8c8184 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_with_cmk_enforcement.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_with_cmk_enforcement.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/SearchUpdateServiceWithCmkEnforcement.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchUpdateServiceWithCmkEnforcement.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_with_semantic_search.py b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_with_semantic_search.py new file mode 100644 index 000000000000..b79877c0859a --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_with_semantic_search.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.search import SearchManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-search +# USAGE + python search_update_service_with_semantic_search.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SearchManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.services.update( + resource_group_name="rg1", + search_service_name="mysearchservice", + service={ + "properties": {"replicaCount": 2, "semanticSearch": "standard"}, + "tags": {"app-name": "My e-commerce app", "new-tag": "Adding a new tag"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchUpdateServiceWithSemanticSearch.json +if __name__ == "__main__": + main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/update_private_endpoint_connection.py b/sdk/search/azure-mgmt-search/generated_samples/update_private_endpoint_connection.py index 44510934209a..9e6c2b3d2585 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/update_private_endpoint_connection.py +++ b/sdk/search/azure-mgmt-search/generated_samples/update_private_endpoint_connection.py @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2022-09-01/examples/UpdatePrivateEndpointConnection.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/UpdatePrivateEndpointConnection.json if __name__ == "__main__": main()