diff --git a/sdk/search/azure-mgmt-search/CHANGELOG.md b/sdk/search/azure-mgmt-search/CHANGELOG.md index b2041f08709e..f8abd9336fde 100644 --- a/sdk/search/azure-mgmt-search/CHANGELOG.md +++ b/sdk/search/azure-mgmt-search/CHANGELOG.md @@ -1,5 +1,33 @@ # Release History +## 9.2.0b3 (2025-02-24) + +### Features Added + + - Client `SearchManagementClient` added operation group `offerings` + - Client `SearchManagementClient` added operation group `service` + - Model `SearchService` added property `system_data` + - Model `SearchService` added property `endpoint` + - Model `SearchService` added property `compute_type` + - Model `SearchService` added property `upgrade_available` + - Model `SearchService` added property `service_upgrade_date` + - Model `SearchServiceUpdate` added property `system_data` + - Model `SearchServiceUpdate` added property `endpoint` + - Model `SearchServiceUpdate` added property `compute_type` + - Model `SearchServiceUpdate` added property `upgrade_available` + - Model `SearchServiceUpdate` added property `service_upgrade_date` + - Added enum `ComputeType` + - Added enum `CreatedByType` + - Added enum `FeatureName` + - Added model `FeatureOffering` + - Added model `OfferingsByRegion` + - Added model `OfferingsListResult` + - Added model `SkuOffering` + - Added model `SkuOfferingLimits` + - Added model `SystemData` + - Added model `OfferingsOperations` + - Added model `ServiceOperations` + ## 9.2.0b2 (2024-07-18) ### Other Changes diff --git a/sdk/search/azure-mgmt-search/_meta.json b/sdk/search/azure-mgmt-search/_meta.json index ded015878367..ce6f5a783635 100644 --- a/sdk/search/azure-mgmt-search/_meta.json +++ b/sdk/search/azure-mgmt-search/_meta.json @@ -1,11 +1,11 @@ { - "commit": "32f566eb38af9593cfc1ed183362471c50d67fb2", + "commit": "ae6e92d62421bfafa2b695d742f3820d5de204eb", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.10.2", "use": [ - "@autorest/python@6.13.16", + "@autorest/python@6.27.4", "@autorest/modelerfour@4.27.0" ], - "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.13.16 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "autorest_command": "autorest specification/search/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.27.4 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --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/__init__.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/__init__.py index a55bcb4e1a94..bed79077840d 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/__init__.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._search_management_client import SearchManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._search_management_client import SearchManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "SearchManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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 ff7e48afe90c..4209042516fe 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/_configuration.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/_configuration.py @@ -14,11 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SearchManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class SearchManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for SearchManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,13 +28,13 @@ class SearchManagementClientConfiguration: # pylint: disable=too-many-instance- :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 "2024-06-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2025-02-01-preview". 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: - api_version: str = kwargs.pop("api_version", "2024-06-01-preview") + api_version: str = kwargs.pop("api_version", "2025-02-01-preview") 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 a6728b4444f5..7497a0bf8928 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 @@ -8,6 +8,7 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse @@ -20,28 +21,29 @@ from .operations import ( AdminKeysOperations, NetworkSecurityPerimeterConfigurationsOperations, + OfferingsOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueryKeysOperations, SearchManagementClientOperationsMixin, + ServiceOperations, ServicesOperations, SharedPrivateLinkResourcesOperations, UsagesOperations, ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SearchManagementClient( - SearchManagementClientOperationsMixin -): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class SearchManagementClient(SearchManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes """Client that can be used to manage Azure AI Search services and API keys. :ivar operations: Operations operations :vartype operations: azure.mgmt.search.operations.Operations + :ivar offerings: OfferingsOperations operations + :vartype offerings: azure.mgmt.search.operations.OfferingsOperations :ivar admin_keys: AdminKeysOperations operations :vartype admin_keys: azure.mgmt.search.operations.AdminKeysOperations :ivar query_keys: QueryKeysOperations operations @@ -62,6 +64,8 @@ class SearchManagementClient( NetworkSecurityPerimeterConfigurationsOperations operations :vartype network_security_perimeter_configurations: azure.mgmt.search.operations.NetworkSecurityPerimeterConfigurationsOperations + :ivar service: ServiceOperations operations + :vartype service: azure.mgmt.search.operations.ServiceOperations :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 @@ -69,7 +73,7 @@ class SearchManagementClient( :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 "2024-06-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2025-02-01-preview". 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 @@ -111,6 +115,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.offerings = OfferingsOperations(self._client, self._config, self._serialize, self._deserialize) self.admin_keys = AdminKeysOperations(self._client, self._config, self._serialize, self._deserialize) self.query_keys = QueryKeysOperations(self._client, self._config, self._serialize, self._deserialize) self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -127,6 +132,7 @@ def __init__( self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.service = ServiceOperations(self._client, self._config, self._serialize, self._deserialize) def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. @@ -153,7 +159,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: def close(self) -> None: self._client.close() - def __enter__(self) -> "SearchManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self 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 2f781d740827..b24ab2885450 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/_serialization.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/_serialization.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -24,7 +25,6 @@ # # -------------------------------------------------------------------------- -# pylint: skip-file # pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode @@ -52,7 +52,6 @@ MutableMapping, Type, List, - Mapping, ) try: @@ -91,6 +90,8 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: :param data: Input, could be bytes or stream (will be decoded with UTF8) or text :type data: str or bytes or IO :param str content_type: The content type. + :return: The deserialized data. + :rtype: object """ if hasattr(data, "read"): # Assume a stream @@ -112,7 +113,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: try: return json.loads(data_as_str) except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) + raise DeserializationError("JSON is invalid: {}".format(err), err) from err elif "xml" in (content_type or []): try: @@ -144,6 +145,8 @@ def _json_attemp(data): # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -153,6 +156,11 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object """ # Try to use content-type from headers if available content_type = None @@ -182,15 +190,30 @@ class UTC(datetime.tzinfo): """Time Zone info for handling UTC""" def utcoffset(self, dt): - """UTF offset for UTC is 0.""" + """UTF offset for UTC is 0. + + :param datetime.datetime dt: The datetime + :returns: The offset + :rtype: datetime.timedelta + """ return datetime.timedelta(0) def tzname(self, dt): - """Timestamp representation.""" + """Timestamp representation. + + :param datetime.datetime dt: The datetime + :returns: The timestamp representation + :rtype: str + """ return "Z" def dst(self, dt): - """No daylight saving for UTC.""" + """No daylight saving for UTC. + + :param datetime.datetime dt: The datetime + :returns: The daylight saving time + :rtype: datetime.timedelta + """ return datetime.timedelta(hours=1) @@ -204,7 +227,7 @@ class _FixedOffset(datetime.tzinfo): # type: ignore :param datetime.timedelta offset: offset in timedelta format """ - def __init__(self, offset): + def __init__(self, offset) -> None: self.__offset = offset def utcoffset(self, dt): @@ -233,24 +256,26 @@ def __getinitargs__(self): _FLATTEN = re.compile(r"(? None: self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: + for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) elif k in self._validation and self._validation[k].get("readonly", False): @@ -298,13 +330,23 @@ def __init__(self, **kwargs: Any) -> None: setattr(self, k, kwargs[k]) def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ return not self.__eq__(other) def __str__(self) -> str: @@ -324,7 +366,11 @@ def is_xml_model(cls) -> bool: @classmethod def _create_xml_node(cls): - """Create XML node.""" + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ try: xml_map = cls._xml_map # type: ignore except AttributeError: @@ -344,7 +390,9 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) def as_dict( self, @@ -378,12 +426,15 @@ def my_key_transformer(key, attr_desc, value): If you want XML serialization, you can pass the kwargs is_xml=True. + :param bool keep_readonly: If you want to serialize the readonly attributes :param function key_transformer: A key transformer function. :returns: A dict JSON compatible object :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) @classmethod def _infer_class_models(cls): @@ -393,7 +444,7 @@ def _infer_class_models(cls): client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} if cls.__name__ not in client_models: raise ValueError("Not Autorest generated code") - except Exception: + except Exception: # pylint: disable=broad-exception-caught # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. client_models = {cls.__name__: cls} return client_models @@ -406,6 +457,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model :raises: DeserializationError if something went wrong + :rtype: ModelType """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @@ -424,9 +476,11 @@ def from_dict( and last_rest_key_case_insensitive_extractor) :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model :raises: DeserializationError if something went wrong + :rtype: ModelType """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -446,21 +500,25 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access return result @classmethod def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class """ for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): subtype_value = None if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -499,11 +557,13 @@ def _decode_attribute_map_key(key): inside the received data. :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str """ return key.replace("\\.", ".") -class Serializer(object): +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -538,7 +598,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -558,13 +618,16 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None): self.key_transformer = full_restapi_key_transformer self.client_side_validation = True - def _serialize(self, target_obj, data_type=None, **kwargs): + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): """Serialize data into a string according to type. - :param target_obj: The data to be serialized. + :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict :raises: SerializationError if serialization fails. + :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) keep_readonly = kwargs.get("keep_readonly", False) @@ -590,12 +653,14 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized = {} if is_xml_model_serialization: - serialized = target_obj._create_xml_node() + serialized = target_obj._create_xml_node() # pylint: disable=protected-access try: - attributes = target_obj._attribute_map + attributes = target_obj._attribute_map # pylint: disable=protected-access for attr, attr_desc in attributes.items(): attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): continue if attr_name == "additional_properties" and attr_desc["key"] == "": @@ -631,7 +696,8 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if isinstance(new_attr, list): serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): splitted_tag = new_attr.tag.split("}") if len(splitted_tag) == 2: # Namespace @@ -662,17 +728,17 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) raise SerializationError(msg) from err - else: - return serialized + return serialized def body(self, data, data_type, **kwargs): """Serialize data intended for a request body. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict :raises: SerializationError if serialization fails. :raises: ValueError if data is None + :returns: The serialized request body """ # Just in case this is a dict @@ -701,7 +767,7 @@ def body(self, data, data_type, **kwargs): attribute_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, ] - data = deserializer._deserialize(data_type, data) + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access except DeserializationError as err: raise SerializationError("Unable to build a model: " + str(err)) from err @@ -710,9 +776,11 @@ def body(self, data, data_type, **kwargs): def url(self, name, data, data_type, **kwargs): """Serialize data intended for a URL path. - :param data: The data to be serialized. + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str + :returns: The serialized URL path :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -726,21 +794,20 @@ def url(self, name, data, data_type, **kwargs): output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output def query(self, name, data, data_type, **kwargs): """Serialize data intended for a URL query. - :param data: The data to be serialized. + :param str name: The name of the query parameter. + :param object 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, list :raises: TypeError if serialization fails. :raises: ValueError if data is None + :returns: The serialized query parameter """ try: # Treat the list aside, since we don't want to encode the div separator @@ -757,19 +824,20 @@ def query(self, name, data, data_type, **kwargs): output = str(output) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def header(self, name, data, data_type, **kwargs): """Serialize data intended for a request header. - :param data: The data to be serialized. + :param str name: The name of the header. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None + :returns: The serialized header """ try: if data_type in ["[str]"]: @@ -778,21 +846,20 @@ def header(self, name, data, data_type, **kwargs): output = self.serialize_data(data, data_type, **kwargs) if data_type == "bool": output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def serialize_data(self, data, data_type, **kwargs): """Serialize generic data according to supplied data type. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None :raises: AttributeError if required data is None. :raises: ValueError if data is None :raises: SerializationError if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list """ if data is None: raise ValueError("No value for given attribute") @@ -803,7 +870,7 @@ def serialize_data(self, data, data_type, **kwargs): if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) - elif data_type in self.serialize_type: + if data_type in self.serialize_type: return self.serialize_type[data_type](data, **kwargs) # If dependencies is empty, try with current data class @@ -819,11 +886,10 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." raise SerializationError(msg.format(data, data_type)) from err - else: - return self._serialize(data, **kwargs) + return self._serialize(data, **kwargs) @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) if custom_serializer: return custom_serializer @@ -839,23 +905,26 @@ def serialize_basic(cls, data, data_type, **kwargs): - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - is_xml bool : If set, use xml_basic_types_serializers - :param data: Object to be serialized. + :param obj data: Object to be serialized. :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec + return eval(data_type)(data) # nosec # pylint: disable=eval-used @classmethod def serialize_unicode(cls, data): """Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. - :param data: Object to be serialized. + :param str data: Object to be serialized. :rtype: str + :return: serialized object """ try: # If I received an enum, return its value return data.value @@ -869,8 +938,7 @@ def serialize_unicode(cls, data): return data except NameError: return str(data) - else: - return str(data) + return str(data) def serialize_iter(self, data, iter_type, div=None, **kwargs): """Serialize iterable. @@ -880,15 +948,13 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialization_ctxt['type'] should be same as data_type. - is_xml bool : If set, serialize as XML - :param list attr: Object to be serialized. + :param list data: Object to be serialized. :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - 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 + :return: serialized iterable """ if isinstance(data, str): raise SerializationError("Refuse str type as a valid iter type.") @@ -943,9 +1009,8 @@ def serialize_dict(self, attr, dict_type, **kwargs): :param dict attr: Object to be serialized. :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. :rtype: dict + :return: serialized dictionary """ serialization_ctxt = kwargs.get("serialization_ctxt", {}) serialized = {} @@ -969,7 +1034,7 @@ def serialize_dict(self, attr, dict_type, **kwargs): return serialized - def serialize_object(self, attr, **kwargs): + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Serialize a generic object. This will be handled as a dictionary. If object passed in is not a basic type (str, int, float, dict, list) it will simply be @@ -977,6 +1042,7 @@ def serialize_object(self, attr, **kwargs): :param dict attr: Object to be serialized. :rtype: dict or str + :return: serialized object """ if attr is None: return None @@ -1001,7 +1067,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_decimal(attr) # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): + if obj_type in self.dependencies.values() or isinstance(attr, Model): return self._serialize(attr) if obj_type == dict: @@ -1032,56 +1098,61 @@ def serialize_enum(attr, enum_obj=None): try: enum_obj(result) # type: ignore return result - except ValueError: + except ValueError as exc: for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) + raise SerializationError(error.format(attr, enum_obj)) from exc @staticmethod - def serialize_bytearray(attr, **kwargs): + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument """Serialize bytearray into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ return b64encode(attr).decode() @staticmethod - def serialize_base64(attr, **kwargs): + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument """Serialize str into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ encoded = b64encode(attr).decode("ascii") return encoded.strip("=").replace("+", "-").replace("/", "_") @staticmethod - def serialize_decimal(attr, **kwargs): + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument """Serialize Decimal object to float. - :param attr: Object to be serialized. + :param decimal attr: Object to be serialized. :rtype: float + :return: serialized decimal """ return float(attr) @staticmethod - def serialize_long(attr, **kwargs): + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument """Serialize long (Py2) or int (Py3). - :param attr: Object to be serialized. + :param int attr: Object to be serialized. :rtype: int/long + :return: serialized long """ return _long_type(attr) @staticmethod - def serialize_date(attr, **kwargs): + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument """Serialize Date object into ISO-8601 formatted string. :param Date attr: Object to be serialized. :rtype: str + :return: serialized date """ if isinstance(attr, str): attr = isodate.parse_date(attr) @@ -1089,11 +1160,12 @@ def serialize_date(attr, **kwargs): return t @staticmethod - def serialize_time(attr, **kwargs): + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument """Serialize Time object into ISO-8601 formatted string. :param datetime.time attr: Object to be serialized. :rtype: str + :return: serialized time """ if isinstance(attr, str): attr = isodate.parse_time(attr) @@ -1103,30 +1175,32 @@ def serialize_time(attr, **kwargs): return t @staticmethod - def serialize_duration(attr, **kwargs): + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument """Serialize TimeDelta object into ISO-8601 formatted string. :param TimeDelta attr: Object to be serialized. :rtype: str + :return: serialized duration """ if isinstance(attr, str): attr = isodate.parse_duration(attr) return isodate.duration_isoformat(attr) @staticmethod - def serialize_rfc(attr, **kwargs): + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into RFC-1123 formatted string. :param Datetime attr: Object to be serialized. :rtype: str :raises: TypeError if format invalid. + :return: serialized rfc """ try: if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( Serializer.days[utc.tm_wday], @@ -1139,12 +1213,13 @@ def serialize_rfc(attr, **kwargs): ) @staticmethod - def serialize_iso(attr, **kwargs): + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into ISO-8601 formatted string. :param Datetime attr: Object to be serialized. :rtype: str :raises: SerializationError if format invalid. + :return: serialized iso """ if isinstance(attr, str): attr = isodate.parse_datetime(attr) @@ -1170,13 +1245,14 @@ def serialize_iso(attr, **kwargs): raise TypeError(msg) from err @staticmethod - def serialize_unix(attr, **kwargs): + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into IntTime format. This is represented as seconds. :param Datetime attr: Object to be serialized. :rtype: int :raises: SerializationError if format invalid + :return: serialied unix """ if isinstance(attr, int): return attr @@ -1184,11 +1260,11 @@ def serialize_unix(attr, **kwargs): if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc -def rest_key_extractor(attr, attr_desc, data): +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument key = attr_desc["key"] working_data = data @@ -1209,7 +1285,9 @@ def rest_key_extractor(attr, attr_desc, data): return working_data.get(key) -def rest_key_case_insensitive_extractor(attr, attr_desc, data): +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): key = attr_desc["key"] working_data = data @@ -1230,17 +1308,29 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): return attribute_key_case_insensitive_extractor(key, None, working_data) -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_extractor(dict_keys[-1], None, data) -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument """Extract the attribute in "data" based on the last part of the JSON path key. This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) @@ -1277,7 +1367,7 @@ def _extract_name_from_internal_type(internal_type): return xml_name -def xml_key_extractor(attr, attr_desc, data): +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements if isinstance(data, dict): return None @@ -1329,22 +1419,21 @@ def xml_key_extractor(attr, attr_desc, data): if is_iter_type: if is_wrapped: return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list + return [] # not wrapped, assume empty list return None # Assume it's not there, maybe an optional node. # If is_iter_type and not wrapped, return all found children if is_iter_type: if not is_wrapped: return children - else: # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + xml_name ) - return list(children[0]) # Might be empty list and that's ok. + ) + return list(children[0]) # Might be empty list and that's ok. # Here it's not a itertype, we should have found one element only or empty if len(children) > 1: @@ -1352,7 +1441,7 @@ def xml_key_extractor(attr, attr_desc, data): return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1361,9 +1450,9 @@ class Deserializer(object): basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1401,11 +1490,12 @@ def __call__(self, target_obj, response_data, content_type=None): :param str content_type: Swagger "produces" if available. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) - def _deserialize(self, target_obj, data): + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements """Call the deserializer on a model. Data needs to be already deserialized as JSON or XML ElementTree @@ -1414,12 +1504,13 @@ def _deserialize(self, target_obj, data): :param object data: Object to deserialize. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ # This is already a model, go recursive just in case if hasattr(data, "_attribute_map"): constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] try: - for attr, mapconfig in data._attribute_map.items(): + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access if attr in constants: continue value = getattr(data, attr) @@ -1438,13 +1529,13 @@ def _deserialize(self, target_obj, data): if isinstance(response, str): return self.deserialize_data(data, response) - elif isinstance(response, type) and issubclass(response, Enum): + if isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: - attributes = response._attribute_map # type: ignore + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1474,9 +1565,8 @@ def _deserialize(self, target_obj, data): except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore raise DeserializationError(msg) from err - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) def _build_additional_properties(self, attribute_map, data): if not self.additional_properties_detection: @@ -1503,6 +1593,8 @@ def _classify_target(self, target, data): :param str target: The target object type to deserialize to. :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple """ if target is None: return None, None @@ -1514,7 +1606,7 @@ def _classify_target(self, target, data): return target, target try: - target = target._classify(data, self.dependencies) # type: ignore + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1529,10 +1621,12 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): :param str target_obj: The target object type to deserialize to. :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object """ try: return self(target_obj, data, content_type=content_type) - except: + except: # pylint: disable=bare-except _LOGGER.debug( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) @@ -1550,10 +1644,12 @@ def _unpack_content(raw_data, content_type=None): If raw_data is something else, bypass all logic and return it directly. - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. :raises JSONDecodeError: If JSON is requested and parsing is impossible. :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. """ # Assume this is enough to detect a Pipeline Response without importing it context = getattr(raw_data, "context", {}) @@ -1577,24 +1673,35 @@ def _unpack_content(raw_data, content_type=None): def _instantiate_model(self, response, attrs, additional_properties=None): """Instantiate a response model passing in deserialized args. - :param response: The response model class. - :param d_attrs: The deserialized response attributes. + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. """ if callable(response): subtype = getattr(response, "_subtype_map", {}) try: - readonly = [k for k, v in response._validation.items() if v.get("readonly")] - const = [k for k, v in response._validation.items() if v.get("constant")] + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) + raise DeserializationError(msg + str(err)) from err else: try: for attr, value in attrs.items(): @@ -1603,15 +1710,16 @@ def _instantiate_model(self, response, attrs, additional_properties=None): except Exception as exp: msg = "Unable to populate response model. " msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) + raise DeserializationError(msg) from exp - def deserialize_data(self, data, data_type): + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements """Process data for deserialization according to data type. :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ if data is None: return data @@ -1625,7 +1733,11 @@ def deserialize_data(self, data, data_type): if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): return data - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: return None data_val = self.deserialize_type[data_type](data) @@ -1645,14 +1757,14 @@ def deserialize_data(self, data, data_type): msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) raise DeserializationError(msg) from err - else: - return self._deserialize(obj_type, data) + return self._deserialize(obj_type, data) def deserialize_iter(self, attr, iter_type): """Deserialize an iterable. :param list attr: Iterable to be deserialized. :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. :rtype: list """ if attr is None: @@ -1669,6 +1781,7 @@ def deserialize_dict(self, attr, dict_type): :param dict/list attr: Dictionary to be deserialized. Also accepts a list of key, value pairs. :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. :rtype: dict """ if isinstance(attr, list): @@ -1679,11 +1792,12 @@ def deserialize_dict(self, attr, dict_type): attr = {el.tag: el.text for el in attr} return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - def deserialize_object(self, attr, **kwargs): + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Deserialize a generic object. This will be handled as a dictionary. :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. :rtype: dict :raises: TypeError if non-builtin datatype encountered. """ @@ -1718,11 +1832,10 @@ def deserialize_object(self, attr, **kwargs): pass return deserialized - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) - def deserialize_basic(self, attr, data_type): + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements """Deserialize basic builtin data type from string. Will attempt to convert to str, int, float and bool. This function will also accept '1', '0', 'true' and 'false' as @@ -1730,6 +1843,7 @@ def deserialize_basic(self, attr, data_type): :param str attr: response string to be deserialized. :param str data_type: deserialization data type. + :return: Deserialized basic type. :rtype: str, int, float or bool :raises: TypeError if string format is not valid. """ @@ -1741,24 +1855,23 @@ def deserialize_basic(self, attr, data_type): if data_type == "str": # None or '', node is empty string. return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, str): + if isinstance(attr, str): if attr.lower() in ["true", "1"]: return True - elif attr.lower() in ["false", "0"]: + if attr.lower() in ["false", "0"]: return False raise TypeError("Invalid boolean value: {}".format(attr)) if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec + return eval(data_type)(attr) # nosec # pylint: disable=eval-used @staticmethod def deserialize_unicode(data): @@ -1766,6 +1879,7 @@ def deserialize_unicode(data): as a string. :param str data: response string to be deserialized. + :return: Deserialized string. :rtype: str or unicode """ # We might be here because we have an enum modeled as string, @@ -1779,8 +1893,7 @@ def deserialize_unicode(data): return data except NameError: return str(data) - else: - return str(data) + return str(data) @staticmethod def deserialize_enum(data, enum_obj): @@ -1792,6 +1905,7 @@ def deserialize_enum(data, enum_obj): :param str data: Response string to be deserialized. If this value is None or invalid it will be returned as-is. :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. :rtype: Enum """ if isinstance(data, enum_obj) or data is None: @@ -1802,9 +1916,9 @@ def deserialize_enum(data, enum_obj): # Workaround. We might consider remove it in the future. try: return list(enum_obj.__members__.values())[data] - except IndexError: + except IndexError as exc: error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) + raise DeserializationError(error.format(data, enum_obj)) from exc try: return enum_obj(str(data)) except ValueError: @@ -1820,6 +1934,7 @@ def deserialize_bytearray(attr): """Deserialize string into bytearray. :param str attr: response string to be deserialized. + :return: Deserialized bytearray :rtype: bytearray :raises: TypeError if string format invalid. """ @@ -1832,6 +1947,7 @@ def deserialize_base64(attr): """Deserialize base64 encoded string into string. :param str attr: response string to be deserialized. + :return: Deserialized base64 string :rtype: bytearray :raises: TypeError if string format invalid. """ @@ -1847,8 +1963,9 @@ def deserialize_decimal(attr): """Deserialize string into Decimal object. :param str attr: response string to be deserialized. - :rtype: Decimal + :return: Deserialized decimal :raises: DeserializationError if string format invalid. + :rtype: decimal """ if isinstance(attr, ET.Element): attr = attr.text @@ -1863,6 +1980,7 @@ def deserialize_long(attr): """Deserialize string into long (Py2) or int (Py3). :param str attr: response string to be deserialized. + :return: Deserialized int :rtype: long or int :raises: ValueError if string format invalid. """ @@ -1875,6 +1993,7 @@ def deserialize_duration(attr): """Deserialize ISO-8601 formatted string into TimeDelta object. :param str attr: response string to be deserialized. + :return: Deserialized duration :rtype: TimeDelta :raises: DeserializationError if string format invalid. """ @@ -1885,14 +2004,14 @@ def deserialize_duration(attr): except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." raise DeserializationError(msg) from err - else: - return duration + return duration @staticmethod def deserialize_date(attr): """Deserialize ISO-8601 formatted string into Date object. :param str attr: response string to be deserialized. + :return: Deserialized date :rtype: Date :raises: DeserializationError if string format invalid. """ @@ -1908,6 +2027,7 @@ def deserialize_time(attr): """Deserialize ISO-8601 formatted string into time object. :param str attr: response string to be deserialized. + :return: Deserialized time :rtype: datetime.time :raises: DeserializationError if string format invalid. """ @@ -1922,6 +2042,7 @@ def deserialize_rfc(attr): """Deserialize RFC-1123 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime :rtype: Datetime :raises: DeserializationError if string format invalid. """ @@ -1937,14 +2058,14 @@ def deserialize_rfc(attr): except ValueError as err: msg = "Cannot deserialize to rfc datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj @staticmethod def deserialize_iso(attr): """Deserialize ISO-8601 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime :rtype: Datetime :raises: DeserializationError if string format invalid. """ @@ -1974,8 +2095,7 @@ def deserialize_iso(attr): except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj @staticmethod def deserialize_unix(attr): @@ -1983,6 +2103,7 @@ def deserialize_unix(attr): This is represented as seconds. :param int attr: Object to be serialized. + :return: Deserialized datetime :rtype: Datetime :raises: DeserializationError if format invalid """ @@ -1994,5 +2115,4 @@ def deserialize_unix(attr): except ValueError as err: msg = "Cannot deserialize to unix datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj 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 7c69bc1c15b5..eb208b575e0a 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/_vendor.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/_vendor.py @@ -8,25 +8,14 @@ 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 - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - class SearchManagementClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" 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 45e4d8f411b7..5ad66e5299ee 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.2.0b2" +VERSION = "9.2.0b3" diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/__init__.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/__init__.py index 6baf3d114500..bf513e736924 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/__init__.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._search_management_client import SearchManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._search_management_client import SearchManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "SearchManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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 fb0abe45928b..0cd83d355a54 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 @@ -14,11 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SearchManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class SearchManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for SearchManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,13 +28,13 @@ class SearchManagementClientConfiguration: # pylint: disable=too-many-instance- :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 "2024-06-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2025-02-01-preview". 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: - api_version: str = kwargs.pop("api_version", "2024-06-01-preview") + api_version: str = kwargs.pop("api_version", "2025-02-01-preview") 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 176552eaf99f..cf72880396aa 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 @@ -8,6 +8,7 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest @@ -20,28 +21,29 @@ from .operations import ( AdminKeysOperations, NetworkSecurityPerimeterConfigurationsOperations, + OfferingsOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueryKeysOperations, SearchManagementClientOperationsMixin, + ServiceOperations, ServicesOperations, SharedPrivateLinkResourcesOperations, UsagesOperations, ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SearchManagementClient( - SearchManagementClientOperationsMixin -): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class SearchManagementClient(SearchManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes """Client that can be used to manage Azure AI Search services and API keys. :ivar operations: Operations operations :vartype operations: azure.mgmt.search.aio.operations.Operations + :ivar offerings: OfferingsOperations operations + :vartype offerings: azure.mgmt.search.aio.operations.OfferingsOperations :ivar admin_keys: AdminKeysOperations operations :vartype admin_keys: azure.mgmt.search.aio.operations.AdminKeysOperations :ivar query_keys: QueryKeysOperations operations @@ -63,6 +65,8 @@ class SearchManagementClient( NetworkSecurityPerimeterConfigurationsOperations operations :vartype network_security_perimeter_configurations: azure.mgmt.search.aio.operations.NetworkSecurityPerimeterConfigurationsOperations + :ivar service: ServiceOperations operations + :vartype service: azure.mgmt.search.aio.operations.ServiceOperations :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 @@ -70,7 +74,7 @@ class SearchManagementClient( :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 "2024-06-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2025-02-01-preview". 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 @@ -112,6 +116,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.offerings = OfferingsOperations(self._client, self._config, self._serialize, self._deserialize) self.admin_keys = AdminKeysOperations(self._client, self._config, self._serialize, self._deserialize) self.query_keys = QueryKeysOperations(self._client, self._config, self._serialize, self._deserialize) self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -128,6 +133,7 @@ def __init__( self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.service = ServiceOperations(self._client, self._config, self._serialize, self._deserialize) def _send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any @@ -156,7 +162,7 @@ def _send_request( async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "SearchManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self 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 index f66a40025d67..82391ad43bfe 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_vendor.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/_vendor.py @@ -8,12 +8,9 @@ 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 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 57f8554fb6d4..b13d6db0d760 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 @@ -5,24 +5,33 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._operations import Operations -from ._admin_keys_operations import AdminKeysOperations -from ._query_keys_operations import QueryKeysOperations -from ._services_operations import ServicesOperations -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 ._network_security_perimeter_configurations_operations import NetworkSecurityPerimeterConfigurationsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import Operations # type: ignore +from ._offerings_operations import OfferingsOperations # type: ignore +from ._admin_keys_operations import AdminKeysOperations # type: ignore +from ._query_keys_operations import QueryKeysOperations # type: ignore +from ._services_operations import ServicesOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._shared_private_link_resources_operations import SharedPrivateLinkResourcesOperations # type: ignore +from ._usages_operations import UsagesOperations # type: ignore +from ._search_management_client_operations import SearchManagementClientOperationsMixin # type: ignore +from ._network_security_perimeter_configurations_operations import NetworkSecurityPerimeterConfigurationsOperations # type: ignore +from ._service_operations import ServiceOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "Operations", + "OfferingsOperations", "AdminKeysOperations", "QueryKeysOperations", "ServicesOperations", @@ -32,6 +41,7 @@ "UsagesOperations", "SearchManagementClientOperationsMixin", "NetworkSecurityPerimeterConfigurationsOperations", + "ServiceOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _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 f7eb031b0a54..27d722ba07bc 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,21 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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._admin_keys_operations import build_get_request, build_regenerate_request -from .._vendor import SearchManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -82,7 +78,7 @@ async def get( :rtype: ~azure.mgmt.search.models.AdminKeyResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -109,7 +105,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -123,7 +118,7 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AdminKeyResult", pipeline_response) + deserialized = self._deserialize("AdminKeyResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -161,7 +156,7 @@ async def regenerate( :rtype: ~azure.mgmt.search.models.AdminKeyResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -189,7 +184,6 @@ async def regenerate( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -203,7 +197,7 @@ async def regenerate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AdminKeyResult", pipeline_response) + deserialized = self._deserialize("AdminKeyResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_network_security_perimeter_configurations_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_network_security_perimeter_configurations_operations.py index 5f65a3ba9374..344c7c736c1a 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_network_security_perimeter_configurations_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_network_security_perimeter_configurations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar, Union, cast +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, Optional, TypeVar, Union, cast import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +16,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,18 +30,16 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._network_security_perimeter_configurations_operations import ( build_get_request, build_list_by_service_request, build_reconcile_request, ) -from .._vendor import SearchManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -89,7 +87,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NetworkSecurityPerimeterConfigurationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -108,7 +106,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -124,7 +121,6 @@ def prepare_request(next_link=None): _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 @@ -171,7 +167,7 @@ async def get( :rtype: ~azure.mgmt.search.models.NetworkSecurityPerimeterConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,7 +190,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -208,17 +203,17 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response) + deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _reconcile_initial( # pylint: disable=inconsistent-return-statements + async def _reconcile_initial( self, resource_group_name: str, search_service_name: str, nsp_config_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -230,7 +225,7 @@ async def _reconcile_initial( # pylint: disable=inconsistent-return-statements _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[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_reconcile_request( resource_group_name=resource_group_name, @@ -241,10 +236,10 @@ async def _reconcile_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -252,14 +247,22 @@ async def _reconcile_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_reconcile( @@ -290,7 +293,7 @@ async def begin_reconcile( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._reconcile_initial( # type: ignore + raw_result = await self._reconcile_initial( resource_group_name=resource_group_name, search_service_name=search_service_name, nsp_config_name=nsp_config_name, @@ -300,6 +303,7 @@ async def begin_reconcile( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_offerings_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_offerings_operations.py new file mode 100644 index 000000000000..ecc550ea4617 --- /dev/null +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_offerings_operations.py @@ -0,0 +1,128 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +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.rest import AsyncHttpResponse, 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 ...operations._offerings_operations import build_list_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class OfferingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.search.aio.SearchManagementClient`'s + :attr:`offerings` 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(self, **kwargs: Any) -> AsyncIterable["_models.OfferingsByRegion"]: + """Lists all of the features and SKUs offered by the Azure AI Search service in each region. + + :return: An iterator like instance of either OfferingsByRegion or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.search.models.OfferingsByRegion] + :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.OfferingsListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OfferingsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) 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 ef36b60ab7bd..548b1baef676 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,21 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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._operations import build_list_request -from .._vendor import SearchManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +68,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,7 +84,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -104,7 +99,6 @@ def prepare_request(next_link=None): _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 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 090131cb3904..13c1e9205b6e 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -21,27 +20,24 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace 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._private_endpoint_connections_operations import ( build_delete_request, build_get_request, build_list_by_service_request, build_update_request, ) -from .._vendor import SearchManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -180,7 +176,7 @@ async def update( :rtype: ~azure.mgmt.search.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,7 +215,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -233,7 +228,7 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -271,7 +266,7 @@ async def get( :rtype: ~azure.mgmt.search.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -299,7 +294,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -313,7 +307,7 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -350,7 +344,7 @@ async def delete( :rtype: ~azure.mgmt.search.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -378,7 +372,6 @@ async def delete( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -394,7 +387,7 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -435,7 +428,7 @@ def list_by_service( 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,7 +451,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -474,7 +466,6 @@ def prepare_request(next_link=None): _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 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 f695fefa2666..8772e68b9a3b 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,21 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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._private_link_resources_operations import build_list_supported_request -from .._vendor import SearchManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -90,7 +86,7 @@ def list_supported( 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -113,7 +109,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -129,7 +124,6 @@ def prepare_request(next_link=None): _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 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 981561d3b15e..7c6b36744dc0 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,26 +19,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace 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._query_keys_operations import ( build_create_request, build_delete_request, build_list_by_search_service_request, ) -from .._vendor import SearchManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -93,7 +89,7 @@ async def create( :rtype: ~azure.mgmt.search.models.QueryKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,7 +117,6 @@ async def create( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -135,7 +130,7 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("QueryKey", pipeline_response) + deserialized = self._deserialize("QueryKey", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -174,7 +169,7 @@ def list_by_search_service( 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,7 +192,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -213,7 +207,6 @@ def prepare_request(next_link=None): _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 @@ -243,7 +236,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def delete( self, resource_group_name: str, search_service_name: str, @@ -273,7 +266,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -301,7 +294,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False 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 index 546248fbbae6..9c15fa6cfd74 100644 --- 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,21 +17,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +44,7 @@ async def usage_by_subscription_sku( search_management_request_options: Optional[_models.SearchManagementRequestOptions] = None, **kwargs: Any ) -> _models.QuotaUsageResult: - """Gets the quota usage for a search sku in the given subscription. + """Gets the quota usage for a search SKU in the given subscription. .. seealso:: - https://aka.ms/search-manage @@ -63,7 +60,7 @@ async def usage_by_subscription_sku( :rtype: ~azure.mgmt.search.models.QuotaUsageResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,7 +87,6 @@ async def usage_by_subscription_sku( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -104,7 +100,7 @@ async def usage_by_subscription_sku( 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) + deserialized = self._deserialize("QuotaUsageResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_service_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_service_operations.py new file mode 100644 index 000000000000..018ae164fb99 --- /dev/null +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/aio/operations/_service_operations.py @@ -0,0 +1,174 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterator, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, 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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._service_operations import build_upgrade_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.search.aio.SearchManagementClient`'s + :attr:`service` 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") + + async def _upgrade_initial( + self, resource_group_name: str, search_service_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_upgrade_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_upgrade( + self, resource_group_name: str, search_service_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.SearchService]: + """Upgrades the Azure AI Search service to the latest version available. + + :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 AI Search service associated with the + specified resource group. Required. + :type search_service_name: str + :return: An instance of AsyncLROPoller that returns either SearchService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.search.models.SearchService] + :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.SearchService] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._upgrade_initial( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SearchService", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SearchService].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SearchService]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) 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 b27035738233..c1caf7073aa3 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,20 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload +from typing import ( + Any, + AsyncIterable, + AsyncIterator, + Callable, + Dict, + IO, + Literal, + Optional, + TypeVar, + Union, + cast, + overload, +) import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +30,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +44,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._services_operations import ( build_check_name_availability_request, build_create_or_update_request, @@ -41,12 +53,11 @@ build_list_by_subscription_request, build_update_request, ) -from .._vendor import SearchManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,8 +88,8 @@ async def _create_or_update_initial( service: Union[_models.SearchService, IO[bytes]], search_management_request_options: Optional[_models.SearchManagementRequestOptions] = None, **kwargs: Any - ) -> _models.SearchService: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,7 +102,7 @@ async def _create_or_update_initial( 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _client_request_id = None if search_management_request_options is not None: @@ -116,10 +127,10 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -127,14 +138,14 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SearchService", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SearchService", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -165,8 +176,8 @@ async def begin_create_or_update( 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. Search service names must be globally unique since they are part of - the service URI (https://:code:``.search.windows.net). You cannot change the service name - after the service is created. Required. + 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. Required. :type service: ~azure.mgmt.search.models.SearchService @@ -206,8 +217,8 @@ async def begin_create_or_update( 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. Search service names must be globally unique since they are part of - the service URI (https://:code:``.search.windows.net). You cannot change the service name - after the service is created. Required. + 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. Required. :type service: IO[bytes] @@ -245,8 +256,8 @@ async def begin_create_or_update( 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. Search service names must be globally unique since they are part of - the service URI (https://:code:``.search.windows.net). You cannot change the service name - after the service is created. Required. + 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 SearchService type or a IO[bytes] type. Required. @@ -281,10 +292,11 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SearchService", pipeline_response) + deserialized = self._deserialize("SearchService", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -403,7 +415,7 @@ async def update( :rtype: ~azure.mgmt.search.models.SearchService :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -441,7 +453,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -455,7 +466,7 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SearchService", pipeline_response) + deserialized = self._deserialize("SearchService", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -488,7 +499,7 @@ async def get( :rtype: ~azure.mgmt.search.models.SearchService :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -515,7 +526,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -529,7 +539,7 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SearchService", pipeline_response) + deserialized = self._deserialize("SearchService", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -537,7 +547,7 @@ async def get( return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def delete( self, resource_group_name: str, search_service_name: str, @@ -562,7 +572,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -589,7 +599,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -634,7 +643,7 @@ def list_by_resource_group( 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -656,7 +665,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -672,7 +680,6 @@ def prepare_request(next_link=None): _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 @@ -723,7 +730,7 @@ def list_by_subscription( 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -744,7 +751,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -760,7 +766,6 @@ def prepare_request(next_link=None): _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 @@ -797,8 +802,8 @@ async def check_name_availability( **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Checks whether or not the given search service name is available for use. Search service names - must be globally unique since they are part of the service URI - (https://:code:``.search.windows.net). + must be globally unique since they are part of the service URI (https://\\ + :code:``.search.windows.net). .. seealso:: - https://aka.ms/search-manage @@ -814,7 +819,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.search.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -845,7 +850,6 @@ async def check_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -859,7 +863,7 @@ async def check_name_availability( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore 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 88198554e1c3..26f389a78177 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +17,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,19 +31,17 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._shared_private_link_resources_operations import ( build_create_or_update_request, build_delete_request, build_get_request, build_list_by_service_request, ) -from .._vendor import SearchManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -75,8 +73,8 @@ async def _create_or_update_initial( shared_private_link_resource: Union[_models.SharedPrivateLinkResource, IO[bytes]], search_management_request_options: Optional[_models.SearchManagementRequestOptions] = None, **kwargs: Any - ) -> Optional[_models.SharedPrivateLinkResource]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,7 +87,7 @@ async def _create_or_update_initial( 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _client_request_id = None if search_management_request_options is not None: @@ -115,10 +113,10 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -126,12 +124,14 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -282,10 +282,11 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -341,7 +342,7 @@ async def get( :rtype: ~azure.mgmt.search.models.SharedPrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,7 +370,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -383,22 +383,22 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, search_service_name: str, shared_private_link_resource_name: str, search_management_request_options: Optional[_models.SearchManagementRequestOptions] = None, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -410,7 +410,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _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[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _client_request_id = None if search_management_request_options is not None: @@ -426,10 +426,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -437,11 +437,19 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202, 204, 404]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -482,7 +490,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, search_service_name=search_service_name, shared_private_link_resource_name=shared_private_link_resource_name, @@ -493,6 +501,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -551,7 +560,7 @@ def list_by_service( 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,7 +583,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -590,7 +598,6 @@ def prepare_request(next_link=None): _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 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 index 48b7a81edbe4..6ba2b2239ff9 100644 --- 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,21 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -85,7 +81,7 @@ def list_by_subscription( 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -107,7 +103,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -123,7 +118,6 @@ def prepare_request(next_link=None): _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 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 6a441c94798b..7a08476f9e51 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 @@ -5,86 +5,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import AdminKeyResult -from ._models_py3 import AsyncOperationResult -from ._models_py3 import CheckNameAvailabilityInput -from ._models_py3 import CheckNameAvailabilityOutput -from ._models_py3 import CloudErrorBody -from ._models_py3 import DataPlaneAadOrApiKeyAuthOption -from ._models_py3 import DataPlaneAuthOptions -from ._models_py3 import EncryptionWithCmk -from ._models_py3 import Identity -from ._models_py3 import IpRule -from ._models_py3 import ListQueryKeysResult -from ._models_py3 import NSPConfigAccessRule -from ._models_py3 import NSPConfigAccessRuleProperties -from ._models_py3 import NSPConfigAssociation -from ._models_py3 import NSPConfigNetworkSecurityPerimeterRule -from ._models_py3 import NSPConfigPerimeter -from ._models_py3 import NSPConfigProfile -from ._models_py3 import NSPProvisioningIssue -from ._models_py3 import NSPProvisioningIssueProperties -from ._models_py3 import NetworkRuleSet -from ._models_py3 import NetworkSecurityPerimeterConfiguration -from ._models_py3 import NetworkSecurityPerimeterConfigurationListResult -from ._models_py3 import Operation -from ._models_py3 import OperationAvailability -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import OperationLogsSpecification -from ._models_py3 import OperationMetricDimension -from ._models_py3 import OperationMetricsSpecification -from ._models_py3 import OperationProperties -from ._models_py3 import OperationServiceSpecification -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionListResult -from ._models_py3 import PrivateEndpointConnectionProperties -from ._models_py3 import PrivateEndpointConnectionPropertiesPrivateEndpoint -from ._models_py3 import PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourceProperties -from ._models_py3 import PrivateLinkResourcesResult -from ._models_py3 import ProxyResource -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 -from ._models_py3 import SearchServiceListResult -from ._models_py3 import SearchServiceUpdate -from ._models_py3 import ShareablePrivateLinkResourceProperties -from ._models_py3 import ShareablePrivateLinkResourceType -from ._models_py3 import SharedPrivateLinkResource -from ._models_py3 import SharedPrivateLinkResourceListResult -from ._models_py3 import SharedPrivateLinkResourceProperties -from ._models_py3 import Sku -from ._models_py3 import TrackedResource -from ._models_py3 import UserAssignedManagedIdentity +from typing import TYPE_CHECKING -from ._search_management_client_enums import AadAuthFailureMode -from ._search_management_client_enums import AdminKeyKind -from ._search_management_client_enums import HostingMode -from ._search_management_client_enums import IdentityType -from ._search_management_client_enums import PrivateLinkServiceConnectionProvisioningState -from ._search_management_client_enums import PrivateLinkServiceConnectionStatus -from ._search_management_client_enums import ProvisioningState -from ._search_management_client_enums import PublicNetworkAccess -from ._search_management_client_enums import SearchBypass -from ._search_management_client_enums import SearchDisabledDataExfiltrationOption -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 -from ._search_management_client_enums import SharedPrivateLinkResourceStatus -from ._search_management_client_enums import SkuName -from ._search_management_client_enums import UnavailableNameReason +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AdminKeyResult, + AsyncOperationResult, + CheckNameAvailabilityInput, + CheckNameAvailabilityOutput, + CloudErrorBody, + DataPlaneAadOrApiKeyAuthOption, + DataPlaneAuthOptions, + EncryptionWithCmk, + FeatureOffering, + Identity, + IpRule, + ListQueryKeysResult, + NSPConfigAccessRule, + NSPConfigAccessRuleProperties, + NSPConfigAssociation, + NSPConfigNetworkSecurityPerimeterRule, + NSPConfigPerimeter, + NSPConfigProfile, + NSPProvisioningIssue, + NSPProvisioningIssueProperties, + NetworkRuleSet, + NetworkSecurityPerimeterConfiguration, + NetworkSecurityPerimeterConfigurationListResult, + OfferingsByRegion, + OfferingsListResult, + Operation, + OperationAvailability, + OperationDisplay, + OperationListResult, + OperationLogsSpecification, + OperationMetricDimension, + OperationMetricsSpecification, + OperationProperties, + OperationServiceSpecification, + PrivateEndpointConnection, + PrivateEndpointConnectionListResult, + PrivateEndpointConnectionProperties, + PrivateEndpointConnectionPropertiesPrivateEndpoint, + PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState, + PrivateLinkResource, + PrivateLinkResourceProperties, + PrivateLinkResourcesResult, + ProxyResource, + QueryKey, + QuotaUsageResult, + QuotaUsageResultName, + QuotaUsagesListResult, + Resource, + SearchManagementRequestOptions, + SearchService, + SearchServiceListResult, + SearchServiceUpdate, + ShareablePrivateLinkResourceProperties, + ShareablePrivateLinkResourceType, + SharedPrivateLinkResource, + SharedPrivateLinkResourceListResult, + SharedPrivateLinkResourceProperties, + Sku, + SkuOffering, + SkuOfferingLimits, + SystemData, + TrackedResource, + UserAssignedManagedIdentity, +) + +from ._search_management_client_enums import ( # type: ignore + AadAuthFailureMode, + AdminKeyKind, + ComputeType, + CreatedByType, + FeatureName, + HostingMode, + IdentityType, + PrivateLinkServiceConnectionProvisioningState, + PrivateLinkServiceConnectionStatus, + ProvisioningState, + PublicNetworkAccess, + SearchBypass, + SearchDisabledDataExfiltrationOption, + SearchEncryptionComplianceStatus, + SearchEncryptionWithCmk, + SearchSemanticSearch, + SearchServiceStatus, + SharedPrivateLinkResourceAsyncOperationResult, + SharedPrivateLinkResourceProvisioningState, + SharedPrivateLinkResourceStatus, + SkuName, + UnavailableNameReason, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -96,6 +116,7 @@ "DataPlaneAadOrApiKeyAuthOption", "DataPlaneAuthOptions", "EncryptionWithCmk", + "FeatureOffering", "Identity", "IpRule", "ListQueryKeysResult", @@ -110,6 +131,8 @@ "NetworkRuleSet", "NetworkSecurityPerimeterConfiguration", "NetworkSecurityPerimeterConfigurationListResult", + "OfferingsByRegion", + "OfferingsListResult", "Operation", "OperationAvailability", "OperationDisplay", @@ -143,10 +166,16 @@ "SharedPrivateLinkResourceListResult", "SharedPrivateLinkResourceProperties", "Sku", + "SkuOffering", + "SkuOfferingLimits", + "SystemData", "TrackedResource", "UserAssignedManagedIdentity", "AadAuthFailureMode", "AdminKeyKind", + "ComputeType", + "CreatedByType", + "FeatureName", "HostingMode", "IdentityType", "PrivateLinkServiceConnectionProvisioningState", @@ -165,5 +194,5 @@ "SkuName", "UnavailableNameReason", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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 8b6c06afdf14..30b03f6405fe 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 @@ -1,5 +1,5 @@ -# coding=utf-8 # 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. @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union @@ -15,10 +16,9 @@ if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object @@ -310,6 +310,30 @@ def __init__( self.encryption_compliance_status = None +class FeatureOffering(_serialization.Model): + """FeatureOffering. + + :ivar name: The name of the feature offered in this region. Known values are: "Grok", + "ImageVectorization", "DocumentIntelligence", "QueryRewrite", "S3", "StorageOptimized", + "SemanticSearch", "MegaStore", and "AvailabilityZones". + :vartype name: str or ~azure.mgmt.search.models.FeatureName + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: Optional[Union[str, "_models.FeatureName"]] = None, **kwargs: Any) -> None: + """ + :keyword name: The name of the feature offered in this region. Known values are: "Grok", + "ImageVectorization", "DocumentIntelligence", "QueryRewrite", "S3", "StorageOptimized", + "SemanticSearch", "MegaStore", and "AvailabilityZones". + :paramtype name: str or ~azure.mgmt.search.models.FeatureName + """ + super().__init__(**kwargs) + self.name = name + + class Identity(_serialization.Model): """Details about the search service identity. A null value indicates that the search service has no identity assigned. @@ -943,6 +967,75 @@ def __init__( self.suggested_access_rules = suggested_access_rules +class OfferingsByRegion(_serialization.Model): + """OfferingsByRegion. + + :ivar region_name: The name of the region. + :vartype region_name: str + :ivar features: The list of features offered in this region. + :vartype features: list[~azure.mgmt.search.models.FeatureOffering] + :ivar skus: The list of SKUs offered in this region. + :vartype skus: list[~azure.mgmt.search.models.SkuOffering] + """ + + _attribute_map = { + "region_name": {"key": "regionName", "type": "str"}, + "features": {"key": "features", "type": "[FeatureOffering]"}, + "skus": {"key": "skus", "type": "[SkuOffering]"}, + } + + def __init__( + self, + *, + region_name: Optional[str] = None, + features: Optional[List["_models.FeatureOffering"]] = None, + skus: Optional[List["_models.SkuOffering"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword region_name: The name of the region. + :paramtype region_name: str + :keyword features: The list of features offered in this region. + :paramtype features: list[~azure.mgmt.search.models.FeatureOffering] + :keyword skus: The list of SKUs offered in this region. + :paramtype skus: list[~azure.mgmt.search.models.SkuOffering] + """ + super().__init__(**kwargs) + self.region_name = region_name + self.features = features + self.skus = skus + + +class OfferingsListResult(_serialization.Model): + """The response containing a list of features and SKUs offered in various regions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of regions with their respective features and SKUs offered. + :vartype value: list[~azure.mgmt.search.models.OfferingsByRegion] + :ivar next_link: The URL to get the next set of offerings, if any. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[OfferingsByRegion]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.OfferingsByRegion"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of regions with their respective features and SKUs offered. + :paramtype value: list[~azure.mgmt.search.models.OfferingsByRegion] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + class Operation(_serialization.Model): """Describes a REST API operation. @@ -1770,7 +1863,7 @@ def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kw self.location = location -class SearchService(TrackedResource): # pylint: disable=too-many-instance-attributes +class SearchService(TrackedResource): """Describes an Azure AI Search service and its current state. Variables are only populated by the server, and will be ignored when sending a request. @@ -1794,6 +1887,9 @@ class SearchService(TrackedResource): # pylint: disable=too-many-instance-attri :vartype sku: ~azure.mgmt.search.models.Sku :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.search.models.Identity + :ivar system_data: Azure Resource Manager metadata of the search service containing createdBy + and modifiedBy information. + :vartype system_data: ~azure.mgmt.search.models.SystemData :ivar replica_count: The number of replicas in the search service. If specified, it must be a value between 1 and 12 inclusive for standard SKUs or between 1 and 3 inclusive for basic SKU. :vartype replica_count: int @@ -1801,12 +1897,17 @@ class SearchService(TrackedResource): # pylint: disable=too-many-instance-attri 1, 2, 3, 4, 6, or 12. Values greater than 1 are only valid for standard SKUs. For 'standard3' services with hostingMode set to 'highDensity', the allowed values are between 1 and 3. :vartype partition_count: int + :ivar endpoint: The endpoint of the Azure AI Search service. + :vartype endpoint: str :ivar hosting_mode: Applicable only for the standard3 SKU. You can set this property to enable up to 3 high density partitions that allow up to 1000 indexes, which is much higher than the maximum indexes allowed for any other SKU. For the standard3 SKU, the value is either 'default' or 'highDensity'. For all other SKUs, this value must be 'default'. Known values are: "default" and "highDensity". :vartype hosting_mode: str or ~azure.mgmt.search.models.HostingMode + :ivar compute_type: Configure this property to support the search service using either the + default compute or Azure Confidential Compute. Known values are: "default" and "confidential". + :vartype compute_type: str or ~azure.mgmt.search.models.ComputeType :ivar public_network_access: This value can be set to 'enabled' to avoid breaking changes on existing customer resources and templates. If set to 'disabled', traffic over public interface is not allowed, and private endpoint connections would be the exclusive access method. Known @@ -1871,6 +1972,11 @@ class SearchService(TrackedResource): # pylint: disable=too-many-instance-attri :ivar e_tag: A system generated property representing the service's etag that can be for optimistic concurrency control during updates. :vartype e_tag: str + :ivar upgrade_available: Indicates whether or not the search service has an upgrade available. + :vartype upgrade_available: bool + :ivar service_upgrade_date: The date and time the search service was last upgraded. This field + will be null until the service gets upgraded for the first time. + :vartype service_upgrade_date: ~datetime.datetime """ _validation = { @@ -1878,6 +1984,7 @@ class SearchService(TrackedResource): # pylint: disable=too-many-instance-attri "name": {"readonly": True}, "type": {"readonly": True}, "location": {"required": True}, + "system_data": {"readonly": True}, "replica_count": {"maximum": 12, "minimum": 1}, "partition_count": {"maximum": 12, "minimum": 1}, "status": {"readonly": True}, @@ -1886,6 +1993,8 @@ class SearchService(TrackedResource): # pylint: disable=too-many-instance-attri "private_endpoint_connections": {"readonly": True}, "shared_private_link_resources": {"readonly": True}, "e_tag": {"readonly": True}, + "upgrade_available": {"readonly": True}, + "service_upgrade_date": {"readonly": True}, } _attribute_map = { @@ -1896,9 +2005,12 @@ class SearchService(TrackedResource): # pylint: disable=too-many-instance-attri "location": {"key": "location", "type": "str"}, "sku": {"key": "sku", "type": "Sku"}, "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "replica_count": {"key": "properties.replicaCount", "type": "int"}, "partition_count": {"key": "properties.partitionCount", "type": "int"}, + "endpoint": {"key": "properties.endpoint", "type": "str"}, "hosting_mode": {"key": "properties.hostingMode", "type": "str"}, + "compute_type": {"key": "properties.computeType", "type": "str"}, "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "status_details": {"key": "properties.statusDetails", "type": "str"}, @@ -1918,9 +2030,11 @@ class SearchService(TrackedResource): # pylint: disable=too-many-instance-attri "type": "[SharedPrivateLinkResource]", }, "e_tag": {"key": "properties.eTag", "type": "str"}, + "upgrade_available": {"key": "properties.upgradeAvailable", "type": "bool"}, + "service_upgrade_date": {"key": "properties.serviceUpgradeDate", "type": "iso-8601"}, } - def __init__( + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -1929,7 +2043,9 @@ def __init__( identity: Optional["_models.Identity"] = None, replica_count: int = 1, partition_count: int = 1, + endpoint: Optional[str] = None, hosting_mode: Union[str, "_models.HostingMode"] = "default", + compute_type: Optional[Union[str, "_models.ComputeType"]] = None, public_network_access: Union[str, "_models.PublicNetworkAccess"] = "enabled", network_rule_set: Optional["_models.NetworkRuleSet"] = None, disabled_data_exfiltration_options: Optional[ @@ -1960,12 +2076,17 @@ def __init__( 'standard3' services with hostingMode set to 'highDensity', the allowed values are between 1 and 3. :paramtype partition_count: int + :keyword endpoint: The endpoint of the Azure AI Search service. + :paramtype endpoint: str :keyword hosting_mode: Applicable only for the standard3 SKU. You can set this property to enable up to 3 high density partitions that allow up to 1000 indexes, which is much higher than the maximum indexes allowed for any other SKU. For the standard3 SKU, the value is either 'default' or 'highDensity'. For all other SKUs, this value must be 'default'. Known values are: "default" and "highDensity". :paramtype hosting_mode: str or ~azure.mgmt.search.models.HostingMode + :keyword compute_type: Configure this property to support the search service using either the + default compute or Azure Confidential Compute. Known values are: "default" and "confidential". + :paramtype compute_type: str or ~azure.mgmt.search.models.ComputeType :keyword public_network_access: This value can be set to 'enabled' to avoid breaking changes on existing customer resources and templates. If set to 'disabled', traffic over public interface is not allowed, and private endpoint connections would be the exclusive access method. Known @@ -1998,9 +2119,12 @@ def __init__( super().__init__(tags=tags, location=location, **kwargs) self.sku = sku self.identity = identity + self.system_data = None self.replica_count = replica_count self.partition_count = partition_count + self.endpoint = endpoint self.hosting_mode = hosting_mode + self.compute_type = compute_type self.public_network_access = public_network_access self.status = None self.status_details = None @@ -2014,6 +2138,8 @@ def __init__( self.private_endpoint_connections = None self.shared_private_link_resources = None self.e_tag = None + self.upgrade_available = None + self.service_upgrade_date = None class SearchServiceListResult(_serialization.Model): @@ -2045,7 +2171,7 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class SearchServiceUpdate(Resource): # pylint: disable=too-many-instance-attributes +class SearchServiceUpdate(Resource): """The parameters used to update an Azure AI Search service. Variables are only populated by the server, and will be ignored when sending a request. @@ -2070,6 +2196,9 @@ class SearchServiceUpdate(Resource): # pylint: disable=too-many-instance-attrib :ivar identity: Details about the search service identity. A null value indicates that the search service has no identity assigned. :vartype identity: ~azure.mgmt.search.models.Identity + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.search.models.SystemData :ivar replica_count: The number of replicas in the search service. If specified, it must be a value between 1 and 12 inclusive for standard SKUs or between 1 and 3 inclusive for basic SKU. :vartype replica_count: int @@ -2077,12 +2206,17 @@ class SearchServiceUpdate(Resource): # pylint: disable=too-many-instance-attrib 1, 2, 3, 4, 6, or 12. Values greater than 1 are only valid for standard SKUs. For 'standard3' services with hostingMode set to 'highDensity', the allowed values are between 1 and 3. :vartype partition_count: int + :ivar endpoint: The endpoint of the Azure AI Search service. + :vartype endpoint: str :ivar hosting_mode: Applicable only for the standard3 SKU. You can set this property to enable up to 3 high density partitions that allow up to 1000 indexes, which is much higher than the maximum indexes allowed for any other SKU. For the standard3 SKU, the value is either 'default' or 'highDensity'. For all other SKUs, this value must be 'default'. Known values are: "default" and "highDensity". :vartype hosting_mode: str or ~azure.mgmt.search.models.HostingMode + :ivar compute_type: Configure this property to support the search service using either the + default compute or Azure Confidential Compute. Known values are: "default" and "confidential". + :vartype compute_type: str or ~azure.mgmt.search.models.ComputeType :ivar public_network_access: This value can be set to 'enabled' to avoid breaking changes on existing customer resources and templates. If set to 'disabled', traffic over public interface is not allowed, and private endpoint connections would be the exclusive access method. Known @@ -2147,12 +2281,18 @@ class SearchServiceUpdate(Resource): # pylint: disable=too-many-instance-attrib :ivar e_tag: A system generated property representing the service's etag that can be for optimistic concurrency control during updates. :vartype e_tag: str + :ivar upgrade_available: Indicates whether or not the search service has an upgrade available. + :vartype upgrade_available: bool + :ivar service_upgrade_date: The date and time the search service was last upgraded. This field + will be null until the service gets upgraded for the first time. + :vartype service_upgrade_date: ~datetime.datetime """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "replica_count": {"maximum": 12, "minimum": 1}, "partition_count": {"maximum": 12, "minimum": 1}, "status": {"readonly": True}, @@ -2161,6 +2301,8 @@ class SearchServiceUpdate(Resource): # pylint: disable=too-many-instance-attrib "private_endpoint_connections": {"readonly": True}, "shared_private_link_resources": {"readonly": True}, "e_tag": {"readonly": True}, + "upgrade_available": {"readonly": True}, + "service_upgrade_date": {"readonly": True}, } _attribute_map = { @@ -2171,9 +2313,12 @@ class SearchServiceUpdate(Resource): # pylint: disable=too-many-instance-attrib "location": {"key": "location", "type": "str"}, "tags": {"key": "tags", "type": "{str}"}, "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "replica_count": {"key": "properties.replicaCount", "type": "int"}, "partition_count": {"key": "properties.partitionCount", "type": "int"}, + "endpoint": {"key": "properties.endpoint", "type": "str"}, "hosting_mode": {"key": "properties.hostingMode", "type": "str"}, + "compute_type": {"key": "properties.computeType", "type": "str"}, "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "status_details": {"key": "properties.statusDetails", "type": "str"}, @@ -2193,9 +2338,11 @@ class SearchServiceUpdate(Resource): # pylint: disable=too-many-instance-attrib "type": "[SharedPrivateLinkResource]", }, "e_tag": {"key": "properties.eTag", "type": "str"}, + "upgrade_available": {"key": "properties.upgradeAvailable", "type": "bool"}, + "service_upgrade_date": {"key": "properties.serviceUpgradeDate", "type": "iso-8601"}, } - def __init__( + def __init__( # pylint: disable=too-many-locals self, *, sku: Optional["_models.Sku"] = None, @@ -2204,7 +2351,9 @@ def __init__( identity: Optional["_models.Identity"] = None, replica_count: int = 1, partition_count: int = 1, + endpoint: Optional[str] = None, hosting_mode: Union[str, "_models.HostingMode"] = "default", + compute_type: Optional[Union[str, "_models.ComputeType"]] = None, public_network_access: Union[str, "_models.PublicNetworkAccess"] = "enabled", network_rule_set: Optional["_models.NetworkRuleSet"] = None, disabled_data_exfiltration_options: Optional[ @@ -2238,12 +2387,17 @@ def __init__( 'standard3' services with hostingMode set to 'highDensity', the allowed values are between 1 and 3. :paramtype partition_count: int + :keyword endpoint: The endpoint of the Azure AI Search service. + :paramtype endpoint: str :keyword hosting_mode: Applicable only for the standard3 SKU. You can set this property to enable up to 3 high density partitions that allow up to 1000 indexes, which is much higher than the maximum indexes allowed for any other SKU. For the standard3 SKU, the value is either 'default' or 'highDensity'. For all other SKUs, this value must be 'default'. Known values are: "default" and "highDensity". :paramtype hosting_mode: str or ~azure.mgmt.search.models.HostingMode + :keyword compute_type: Configure this property to support the search service using either the + default compute or Azure Confidential Compute. Known values are: "default" and "confidential". + :paramtype compute_type: str or ~azure.mgmt.search.models.ComputeType :keyword public_network_access: This value can be set to 'enabled' to avoid breaking changes on existing customer resources and templates. If set to 'disabled', traffic over public interface is not allowed, and private endpoint connections would be the exclusive access method. Known @@ -2278,9 +2432,12 @@ def __init__( self.location = location self.tags = tags self.identity = identity + self.system_data = None self.replica_count = replica_count self.partition_count = partition_count + self.endpoint = endpoint self.hosting_mode = hosting_mode + self.compute_type = compute_type self.public_network_access = public_network_access self.status = None self.status_details = None @@ -2294,6 +2451,8 @@ def __init__( self.private_endpoint_connections = None self.shared_private_link_resources = None self.e_tag = None + self.upgrade_available = None + self.service_upgrade_date = None class ShareablePrivateLinkResourceProperties(_serialization.Model): @@ -2555,6 +2714,175 @@ def __init__(self, *, name: Optional[Union[str, "_models.SkuName"]] = None, **kw self.name = name +class SkuOffering(_serialization.Model): + """SkuOffering. + + :ivar sku: Defines the SKU of a search service, which determines billing rate and capacity + limits. + :vartype sku: ~azure.mgmt.search.models.Sku + :ivar limits: The limits associated with this SKU offered in this region. + :vartype limits: ~azure.mgmt.search.models.SkuOfferingLimits + """ + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "limits": {"key": "limits", "type": "SkuOfferingLimits"}, + } + + def __init__( + self, + *, + sku: Optional["_models.Sku"] = None, + limits: Optional["_models.SkuOfferingLimits"] = None, + **kwargs: Any + ) -> None: + """ + :keyword sku: Defines the SKU of a search service, which determines billing rate and capacity + limits. + :paramtype sku: ~azure.mgmt.search.models.Sku + :keyword limits: The limits associated with this SKU offered in this region. + :paramtype limits: ~azure.mgmt.search.models.SkuOfferingLimits + """ + super().__init__(**kwargs) + self.sku = sku + self.limits = limits + + +class SkuOfferingLimits(_serialization.Model): + """The limits associated with this SKU offered in this region. + + :ivar indexes: The maximum number of indexes available for this SKU. + :vartype indexes: int + :ivar indexers: The maximum number of indexers available for this SKU. + :vartype indexers: int + :ivar partition_storage_in_gigabytes: The maximum storage size in Gigabytes available for this + SKU per partition. + :vartype partition_storage_in_gigabytes: int + :ivar partition_vector_storage_in_gigabytes: The maximum vector storage size in Gigabytes + available for this SKU per partition. + :vartype partition_vector_storage_in_gigabytes: int + :ivar search_units: The maximum number of search units available for this SKU. + :vartype search_units: int + :ivar replicas: The maximum number of replicas available for this SKU. + :vartype replicas: int + :ivar partitions: The maximum number of partitions available for this SKU. + :vartype partitions: int + """ + + _attribute_map = { + "indexes": {"key": "indexes", "type": "int"}, + "indexers": {"key": "indexers", "type": "int"}, + "partition_storage_in_gigabytes": {"key": "partitionStorageInGigabytes", "type": "int"}, + "partition_vector_storage_in_gigabytes": {"key": "partitionVectorStorageInGigabytes", "type": "int"}, + "search_units": {"key": "searchUnits", "type": "int"}, + "replicas": {"key": "replicas", "type": "int"}, + "partitions": {"key": "partitions", "type": "int"}, + } + + def __init__( + self, + *, + indexes: Optional[int] = None, + indexers: Optional[int] = None, + partition_storage_in_gigabytes: Optional[int] = None, + partition_vector_storage_in_gigabytes: Optional[int] = None, + search_units: Optional[int] = None, + replicas: Optional[int] = None, + partitions: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword indexes: The maximum number of indexes available for this SKU. + :paramtype indexes: int + :keyword indexers: The maximum number of indexers available for this SKU. + :paramtype indexers: int + :keyword partition_storage_in_gigabytes: The maximum storage size in Gigabytes available for + this SKU per partition. + :paramtype partition_storage_in_gigabytes: int + :keyword partition_vector_storage_in_gigabytes: The maximum vector storage size in Gigabytes + available for this SKU per partition. + :paramtype partition_vector_storage_in_gigabytes: int + :keyword search_units: The maximum number of search units available for this SKU. + :paramtype search_units: int + :keyword replicas: The maximum number of replicas available for this SKU. + :paramtype replicas: int + :keyword partitions: The maximum number of partitions available for this SKU. + :paramtype partitions: int + """ + super().__init__(**kwargs) + self.indexes = indexes + self.indexers = indexers + self.partition_storage_in_gigabytes = partition_storage_in_gigabytes + self.partition_vector_storage_in_gigabytes = partition_vector_storage_in_gigabytes + self.search_units = search_units + self.replicas = replicas + self.partitions = partitions + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.search.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.search.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.search.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.search.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + class UserAssignedManagedIdentity(_serialization.Model): """The details of the user assigned managed identity assigned to the search service. 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 01e586512724..066476445868 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 @@ -32,6 +32,49 @@ class AdminKeyKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The secondary API key for the search service.""" +class ComputeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Configure this property to support the search service using either the default compute or Azure + Confidential Compute. + """ + + DEFAULT = "default" + """Create the service with the default compute.""" + CONFIDENTIAL = "confidential" + """Create the service with Azure Confidential Compute.""" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class FeatureName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the feature offered in this region.""" + + GROK = "Grok" + """Supports Grok feature.""" + IMAGE_VECTORIZATION = "ImageVectorization" + """Supports Image Vectorization feature.""" + DOCUMENT_INTELLIGENCE = "DocumentIntelligence" + """Supports Document Intelligence feature.""" + QUERY_REWRITE = "QueryRewrite" + """Supports Query Rewrite feature.""" + S3 = "S3" + """Supports S3 feature.""" + STORAGE_OPTIMIZED = "StorageOptimized" + """Supports Storage Optimized feature.""" + SEMANTIC_SEARCH = "SemanticSearch" + """Supports Semantic Search feature.""" + MEGA_STORE = "MegaStore" + """Supports Mega Store feature.""" + AVAILABILITY_ZONES = "AvailabilityZones" + """Supports Availability Zones feature.""" + + class HostingMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Applicable only for the standard3 SKU. You can set this property to enable up to 3 high density partitions that allow up to 1000 indexes, which is much higher than the maximum indexes allowed 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 57f8554fb6d4..b13d6db0d760 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 @@ -5,24 +5,33 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._operations import Operations -from ._admin_keys_operations import AdminKeysOperations -from ._query_keys_operations import QueryKeysOperations -from ._services_operations import ServicesOperations -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 ._network_security_perimeter_configurations_operations import NetworkSecurityPerimeterConfigurationsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import Operations # type: ignore +from ._offerings_operations import OfferingsOperations # type: ignore +from ._admin_keys_operations import AdminKeysOperations # type: ignore +from ._query_keys_operations import QueryKeysOperations # type: ignore +from ._services_operations import ServicesOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._shared_private_link_resources_operations import SharedPrivateLinkResourcesOperations # type: ignore +from ._usages_operations import UsagesOperations # type: ignore +from ._search_management_client_operations import SearchManagementClientOperationsMixin # type: ignore +from ._network_security_perimeter_configurations_operations import NetworkSecurityPerimeterConfigurationsOperations # type: ignore +from ._service_operations import ServiceOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "Operations", + "OfferingsOperations", "AdminKeysOperations", "QueryKeysOperations", "ServicesOperations", @@ -32,6 +41,7 @@ "UsagesOperations", "SearchManagementClientOperationsMixin", "NetworkSecurityPerimeterConfigurationsOperations", + "ServiceOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _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 f4535df863f4..f58a210fca8c 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +17,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +47,7 @@ def build_get_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,7 +88,7 @@ def build_regenerate_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -166,7 +163,7 @@ def get( :rtype: ~azure.mgmt.search.models.AdminKeyResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,7 +190,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -207,7 +203,7 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AdminKeyResult", pipeline_response) + deserialized = self._deserialize("AdminKeyResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -245,7 +241,7 @@ def regenerate( :rtype: ~azure.mgmt.search.models.AdminKeyResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -273,7 +269,6 @@ def regenerate( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -287,7 +282,7 @@ def regenerate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AdminKeyResult", pipeline_response) + deserialized = self._deserialize("AdminKeyResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_network_security_perimeter_configurations_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_network_security_perimeter_configurations_operations.py index f82e60c17bd6..30b823d9d8ed 100644 --- a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_network_security_perimeter_configurations_operations.py +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_network_security_perimeter_configurations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar, Union, cast +from typing import Any, Callable, Dict, Iterable, Iterator, Optional, TypeVar, Union, cast import urllib.parse from azure.core.exceptions import ( @@ -16,13 +15,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import SearchManagementClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +48,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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +81,7 @@ def build_get_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -123,7 +122,7 @@ def build_reconcile_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -201,7 +200,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NetworkSecurityPerimeterConfigurationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,7 +219,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -236,7 +234,6 @@ def prepare_request(next_link=None): _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 @@ -283,7 +280,7 @@ def get( :rtype: ~azure.mgmt.search.models.NetworkSecurityPerimeterConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -306,7 +303,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -320,17 +316,17 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response) + deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _reconcile_initial( # pylint: disable=inconsistent-return-statements + def _reconcile_initial( self, resource_group_name: str, search_service_name: str, nsp_config_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -342,7 +338,7 @@ def _reconcile_initial( # pylint: disable=inconsistent-return-statements _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[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_reconcile_request( resource_group_name=resource_group_name, @@ -353,10 +349,10 @@ def _reconcile_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -364,14 +360,22 @@ def _reconcile_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_reconcile( @@ -402,7 +406,7 @@ def begin_reconcile( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._reconcile_initial( # type: ignore + raw_result = self._reconcile_initial( resource_group_name=resource_group_name, search_service_name=search_service_name, nsp_config_name=nsp_config_name, @@ -412,6 +416,7 @@ def begin_reconcile( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_offerings_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_offerings_operations.py new file mode 100644 index 000000000000..45180e68c906 --- /dev/null +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_offerings_operations.py @@ -0,0 +1,150 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +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.rest import HttpRequest, HttpResponse +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 + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +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: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Search/offerings") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class OfferingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.search.SearchManagementClient`'s + :attr:`offerings` 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(self, **kwargs: Any) -> Iterable["_models.OfferingsByRegion"]: + """Lists all of the features and SKUs offered by the Azure AI Search service in each region. + + :return: An iterator like instance of either OfferingsByRegion or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.search.models.OfferingsByRegion] + :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.OfferingsListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OfferingsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) 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 060d196aa209..ad0a0d32c15f 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -20,20 +19,18 @@ ) 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.rest import HttpRequest, HttpResponse 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 if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +42,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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +90,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -109,7 +106,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -125,7 +121,6 @@ def prepare_request(next_link=None): _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 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 6439c82c4bc7..38bd864e066b 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -21,20 +20,18 @@ ) 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.rest import HttpRequest, HttpResponse 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 if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +51,7 @@ def build_update_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -101,7 +98,7 @@ def build_get_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -145,7 +142,7 @@ def build_delete_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,7 +185,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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -351,7 +348,7 @@ def update( :rtype: ~azure.mgmt.search.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -390,7 +387,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -404,7 +400,7 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -442,7 +438,7 @@ def get( :rtype: ~azure.mgmt.search.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -470,7 +466,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -484,7 +479,7 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -521,7 +516,7 @@ def delete( :rtype: ~azure.mgmt.search.models.PrivateEndpointConnection or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -549,7 +544,6 @@ def delete( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -565,7 +559,7 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -605,7 +599,7 @@ def list_by_service( 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -628,7 +622,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -644,7 +637,6 @@ def prepare_request(next_link=None): _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 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 8a7a73f608f1..8d736dc804d0 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -20,20 +19,18 @@ ) 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.rest import HttpRequest, HttpResponse 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 if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +49,7 @@ def build_list_supported_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -132,7 +129,7 @@ def list_supported( 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,7 +152,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -171,7 +167,6 @@ def prepare_request(next_link=None): _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 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 bca4bbc51daa..11c2379550b0 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -20,20 +19,18 @@ ) 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.rest import HttpRequest, HttpResponse 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 if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +50,7 @@ def build_create_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +91,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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -135,7 +132,7 @@ def build_delete_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -214,7 +211,7 @@ def create( :rtype: ~azure.mgmt.search.models.QueryKey :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -242,7 +239,6 @@ def create( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -256,7 +252,7 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("QueryKey", pipeline_response) + deserialized = self._deserialize("QueryKey", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -295,7 +291,7 @@ def list_by_search_service( 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -318,7 +314,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -334,7 +329,6 @@ def prepare_request(next_link=None): _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 @@ -394,7 +388,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -422,7 +416,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False 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 index 84b13d102918..1bd2c4ee34d9 100644 --- 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +17,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 +from .._vendor import SearchManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +43,7 @@ def build_usage_by_subscription_sku_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +80,7 @@ def usage_by_subscription_sku( search_management_request_options: Optional[_models.SearchManagementRequestOptions] = None, **kwargs: Any ) -> _models.QuotaUsageResult: - """Gets the quota usage for a search sku in the given subscription. + """Gets the quota usage for a search SKU in the given subscription. .. seealso:: - https://aka.ms/search-manage @@ -98,7 +96,7 @@ def usage_by_subscription_sku( :rtype: ~azure.mgmt.search.models.QuotaUsageResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -125,7 +123,6 @@ def usage_by_subscription_sku( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -139,7 +136,7 @@ def usage_by_subscription_sku( 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) + deserialized = self._deserialize("QuotaUsageResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_service_operations.py b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_service_operations.py new file mode 100644 index 000000000000..d831fc24511a --- /dev/null +++ b/sdk/search/azure-mgmt-search/azure/mgmt/search/operations/_service_operations.py @@ -0,0 +1,208 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterator, Optional, TypeVar, Union, cast + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_upgrade_request( + resource_group_name: str, search_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/upgrade", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "searchServiceName": _SERIALIZER.url( + "search_service_name", search_service_name, "str", pattern=r"^(?=.{2,60}$)[a-z0-9][a-z0-9]+(-[a-z0-9]+)*$" + ), + "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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.search.SearchManagementClient`'s + :attr:`service` 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") + + def _upgrade_initial(self, resource_group_name: str, search_service_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 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[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_upgrade_request( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_upgrade( + self, resource_group_name: str, search_service_name: str, **kwargs: Any + ) -> LROPoller[_models.SearchService]: + """Upgrades the Azure AI Search service to the latest version available. + + :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 AI Search service associated with the + specified resource group. Required. + :type search_service_name: str + :return: An instance of LROPoller that returns either SearchService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.search.models.SearchService] + :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.SearchService] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._upgrade_initial( + resource_group_name=resource_group_name, + search_service_name=search_service_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SearchService", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SearchService].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SearchService]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) 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 9789a2ca3659..19901aa64e84 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,12 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import SearchManagementClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -96,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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -137,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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -177,7 +177,7 @@ def build_delete_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -212,7 +212,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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -244,7 +244,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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -272,10 +272,9 @@ def build_check_name_availability_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") - type = "searchServices" # Construct URL _url = kwargs.pop( @@ -326,8 +325,8 @@ def _create_or_update_initial( service: Union[_models.SearchService, IO[bytes]], search_management_request_options: Optional[_models.SearchManagementRequestOptions] = None, **kwargs: Any - ) -> _models.SearchService: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -340,7 +339,7 @@ def _create_or_update_initial( 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _client_request_id = None if search_management_request_options is not None: @@ -365,10 +364,10 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -376,14 +375,14 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SearchService", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SearchService", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -414,8 +413,8 @@ def begin_create_or_update( 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. Search service names must be globally unique since they are part of - the service URI (https://:code:``.search.windows.net). You cannot change the service name - after the service is created. Required. + 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. Required. :type service: ~azure.mgmt.search.models.SearchService @@ -455,8 +454,8 @@ def begin_create_or_update( 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. Search service names must be globally unique since they are part of - the service URI (https://:code:``.search.windows.net). You cannot change the service name - after the service is created. Required. + 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. Required. :type service: IO[bytes] @@ -494,8 +493,8 @@ def begin_create_or_update( 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. Search service names must be globally unique since they are part of - the service URI (https://:code:``.search.windows.net). You cannot change the service name - after the service is created. Required. + 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 SearchService type or a IO[bytes] type. Required. @@ -530,10 +529,11 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SearchService", pipeline_response) + deserialized = self._deserialize("SearchService", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -652,7 +652,7 @@ def update( :rtype: ~azure.mgmt.search.models.SearchService :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -690,7 +690,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -704,7 +703,7 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SearchService", pipeline_response) + deserialized = self._deserialize("SearchService", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -737,7 +736,7 @@ def get( :rtype: ~azure.mgmt.search.models.SearchService :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -764,7 +763,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -778,7 +776,7 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SearchService", pipeline_response) + deserialized = self._deserialize("SearchService", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -811,7 +809,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -838,7 +836,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -883,7 +880,7 @@ def list_by_resource_group( 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -905,7 +902,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -921,7 +917,6 @@ def prepare_request(next_link=None): _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 @@ -972,7 +967,7 @@ def list_by_subscription( 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -993,7 +988,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1009,7 +1003,6 @@ def prepare_request(next_link=None): _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 @@ -1046,8 +1039,8 @@ def check_name_availability( **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Checks whether or not the given search service name is available for use. Search service names - must be globally unique since they are part of the service URI - (https://:code:``.search.windows.net). + must be globally unique since they are part of the service URI (https://\\ + :code:``.search.windows.net). .. seealso:: - https://aka.ms/search-manage @@ -1063,7 +1056,7 @@ def check_name_availability( :rtype: ~azure.mgmt.search.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1094,7 +1087,6 @@ def check_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1108,7 +1100,7 @@ def check_name_availability( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore 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 f02acbd0749c..0a8bbf431c45 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +7,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +16,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,12 +31,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import SearchManagementClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -103,7 +102,7 @@ def build_get_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -147,7 +146,7 @@ def build_delete_request( _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", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -190,7 +189,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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -246,8 +245,8 @@ def _create_or_update_initial( shared_private_link_resource: Union[_models.SharedPrivateLinkResource, IO[bytes]], search_management_request_options: Optional[_models.SearchManagementRequestOptions] = None, **kwargs: Any - ) -> Optional[_models.SharedPrivateLinkResource]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -260,7 +259,7 @@ def _create_or_update_initial( 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _client_request_id = None if search_management_request_options is not None: @@ -286,10 +285,10 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -297,12 +296,14 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -453,10 +454,11 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -511,7 +513,7 @@ def get( :rtype: ~azure.mgmt.search.models.SharedPrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -539,7 +541,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -553,22 +554,22 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, search_service_name: str, shared_private_link_resource_name: str, search_management_request_options: Optional[_models.SearchManagementRequestOptions] = None, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -580,7 +581,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _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[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _client_request_id = None if search_management_request_options is not None: @@ -596,10 +597,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -607,11 +608,19 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202, 204, 404]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -652,7 +661,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, search_service_name=search_service_name, shared_private_link_resource_name=shared_private_link_resource_name, @@ -663,6 +672,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -719,7 +729,7 @@ def list_by_service( 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -742,7 +752,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -758,7 +767,6 @@ def prepare_request(next_link=None): _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 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 index 6c9d417fc4cf..b527183fa9d5 100644 --- 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -20,20 +19,18 @@ ) 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.rest import HttpRequest, HttpResponse 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 if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +44,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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,7 +115,7 @@ def list_by_subscription( 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: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -140,7 +137,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -156,7 +152,6 @@ def prepare_request(next_link=None): _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 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 1be49a69e3b5..9f6625d93ffb 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -48,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/CreateOrUpdateSharedPrivateLinkResource.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 b007d3eb50dd..9bd2626314b6 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/DeletePrivateEndpointConnection.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 bce4e99cad5d..2264a196489e 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 @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/DeleteSharedPrivateLinkResource.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 8cca6f78a9d5..9ae655ff4a69 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/GetPrivateEndpointConnection.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 index 0ddd7402f074..976f8fd1cafa 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/get_quota_usage.py +++ b/sdk/search/azure-mgmt-search/generated_samples/get_quota_usage.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/GetQuotaUsage.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 index d85b581ee7ba..89bf35f426b2 100644 --- 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 @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/GetQuotaUsagesList.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 7c5c2729580c..af54a5eec371 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/GetSharedPrivateLinkResource.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 628c7871b604..541f38cff278 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 @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/ListPrivateEndpointConnectionsByService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 ab221679d47a..e8daec3b282f 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 @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/ListSharedPrivateLinkResourcesByService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 b2360b507a59..9ce7c82a7afc 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 @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/ListSupportedPrivateLinkResources.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/ListSupportedPrivateLinkResources.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/network_security_perimeter_configurations_get.py b/sdk/search/azure-mgmt-search/generated_samples/network_security_perimeter_configurations_get.py index 135b7244c473..5c7af4ee40be 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/network_security_perimeter_configurations_get.py +++ b/sdk/search/azure-mgmt-search/generated_samples/network_security_perimeter_configurations_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurationsGet.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/NetworkSecurityPerimeterConfigurationsGet.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/network_security_perimeter_configurations_list_by_service.py b/sdk/search/azure-mgmt-search/generated_samples/network_security_perimeter_configurations_list_by_service.py index 551a4c705935..52a49088720e 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/network_security_perimeter_configurations_list_by_service.py +++ b/sdk/search/azure-mgmt-search/generated_samples/network_security_perimeter_configurations_list_by_service.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurationsListByService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/NetworkSecurityPerimeterConfigurationsListByService.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/network_security_perimeter_configurations_reconcile.py b/sdk/search/azure-mgmt-search/generated_samples/network_security_perimeter_configurations_reconcile.py index a6d0f7a613e2..6c95d3183c37 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/network_security_perimeter_configurations_reconcile.py +++ b/sdk/search/azure-mgmt-search/generated_samples/network_security_perimeter_configurations_reconcile.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurationsReconcile.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/NetworkSecurityPerimeterConfigurationsReconcile.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 c91a7ede9793..220a13de75bd 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -37,7 +35,7 @@ def main(): search_service_name="mysearchservice", service={ "location": "westus", - "properties": {"hostingMode": "default", "partitionCount": 1, "replicaCount": 3}, + "properties": {"computeType": "default", "hostingMode": "default", "partitionCount": 1, "replicaCount": 3}, "sku": {"name": "standard"}, "tags": {"app-name": "My e-commerce app"}, }, @@ -45,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCreateOrUpdateService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 21aa2daf1e6d..7a25dbcf4594 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -39,6 +37,7 @@ def main(): "location": "westus", "properties": { "authOptions": {"aadOrApiKey": {"aadAuthFailureMode": "http401WithBearerChallenge"}}, + "computeType": "default", "hostingMode": "default", "partitionCount": 1, "replicaCount": 3, @@ -50,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCreateOrUpdateServiceAuthOptions.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 c849350b6805..bb6122f9de89 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -37,7 +35,13 @@ def main(): search_service_name="mysearchservice", service={ "location": "westus", - "properties": {"disableLocalAuth": True, "hostingMode": "default", "partitionCount": 1, "replicaCount": 3}, + "properties": { + "computeType": "default", + "disableLocalAuth": True, + "hostingMode": "default", + "partitionCount": 1, + "replicaCount": 3, + }, "sku": {"name": "standard"}, "tags": {"app-name": "My e-commerce app"}, }, @@ -45,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCreateOrUpdateServiceDisableLocalAuth.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 2a226e0a7948..68c0f33622b6 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -38,6 +36,7 @@ def main(): service={ "location": "westus", "properties": { + "computeType": "default", "hostingMode": "default", "partitionCount": 1, "publicNetworkAccess": "disabled", @@ -50,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCreateOrUpdateServiceToAllowAccessFromPrivateEndpoints.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 06c1fb38a007..7caefdcd1340 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -38,6 +36,7 @@ def main(): service={ "location": "westus", "properties": { + "computeType": "default", "hostingMode": "default", "networkRuleSet": {"ipRules": [{"value": "123.4.5.6"}, {"value": "123.4.6.0/18"}]}, "partitionCount": 1, @@ -50,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPs.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPs.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_and_bypass.py b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_to_allow_access_from_public_custom_ips_and_bypass.py index fded6931791e..f2cc81d01f2d 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_to_allow_access_from_public_custom_ips_and_bypass.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_to_allow_access_from_public_custom_ips_and_bypass.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -38,6 +36,7 @@ def main(): service={ "location": "westus", "properties": { + "computeType": "default", "hostingMode": "default", "networkRuleSet": { "bypass": "AzurePortal", @@ -53,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPsAndBypass.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPsAndBypass.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 4ccb92ac8bc4..d957e2b08350 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -38,6 +36,7 @@ def main(): service={ "location": "westus", "properties": { + "computeType": "default", "encryptionWithCmk": {"enforcement": "Enabled"}, "hostingMode": "default", "partitionCount": 1, @@ -50,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCreateOrUpdateServiceWithCmkEnforcement.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/SearchCreateOrUpdateServiceWithCmkEnforcement.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_with_data_exfiltration.py b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_with_data_exfiltration.py index e591766a54f7..af61583249b2 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_with_data_exfiltration.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_create_or_update_service_with_data_exfiltration.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -38,6 +36,7 @@ def main(): service={ "location": "westus", "properties": { + "computeType": "default", "disabledDataExfiltrationOptions": ["All"], "hostingMode": "default", "partitionCount": 1, @@ -50,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCreateOrUpdateServiceWithDataExfiltration.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/SearchCreateOrUpdateServiceWithDataExfiltration.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 104a55ba6c83..44dfe736534f 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -43,7 +41,7 @@ def main(): }, }, "location": "westus", - "properties": {"hostingMode": "default", "partitionCount": 1, "replicaCount": 3}, + "properties": {"computeType": "default", "hostingMode": "default", "partitionCount": 1, "replicaCount": 3}, "sku": {"name": "standard"}, "tags": {"app-name": "My e-commerce app"}, }, @@ -51,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCreateOrUpdateServiceWithIdentity.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 index 50e2e25dd481..03496766f6f3 100644 --- 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -37,7 +35,13 @@ def main(): search_service_name="mysearchservice", service={ "location": "westus", - "properties": {"hostingMode": "default", "partitionCount": 1, "replicaCount": 3, "semanticSearch": "free"}, + "properties": { + "computeType": "default", + "hostingMode": "default", + "partitionCount": 1, + "replicaCount": 3, + "semanticSearch": "free", + }, "sku": {"name": "standard"}, "tags": {"app-name": "My e-commerce app"}, }, @@ -45,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCreateOrUpdateWithSemanticSearch.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 1d3be4ea9695..15f76a8cd0b5 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCreateQueryKey.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 bbc5dd944922..9bb6d3372568 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 @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchDeleteQueryKey.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 d715438932b1..fd78708a4be5 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 @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchDeleteService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 014e2cfe0dfb..52ce1e98b366 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 @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchGetAdminKeys.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 89180b21c021..5e7505e50e00 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 @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchGetService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/SearchGetService.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_list_offerings.py b/sdk/search/azure-mgmt-search/generated_samples/search_list_offerings.py new file mode 100644 index 000000000000..551f28f83346 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_samples/search_list_offerings.py @@ -0,0 +1,40 @@ +# 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_list_offerings.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="SUBSCRIPTION_ID", + ) + + response = client.offerings.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/SearchListOfferings.json +if __name__ == "__main__": + main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_list_operations.py b/sdk/search/azure-mgmt-search/generated_samples/search_list_operations.py index 9eed372d1c2f..a7431ca1afc0 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_list_operations.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_list_operations.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchListOperations.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/SearchListOperations.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 57fba1fc7bdc..256ef2ca8d34 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 @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchListQueryKeysBySearchService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 da32cc14e3e3..d3ecd3208fb0 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 @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchListServicesByResourceGroup.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 6a79c4cd196e..ea7647c56a5a 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 @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchListServicesBySubscription.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 5a8992fa3aec..4d8d40bda51a 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 @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchRegenerateAdminKey.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 2fc7c08c6a92..c2706755f0a5 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -43,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchUpdateService.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 adeae276b8cd..5aacaabba3fc 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -46,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchUpdateServiceAuthOptions.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 e32679ab3015..24b5d78c54c9 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -43,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchUpdateServiceDisableLocalAuth.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 bc1fb65456df..b508108e46de 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -40,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchUpdateServiceToAllowAccessFromPrivateEndpoints.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 1baa5ed061d3..d317b20fdaee 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -47,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchUpdateServiceToAllowAccessFromPublicCustomIPs.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/SearchUpdateServiceToAllowAccessFromPublicCustomIPs.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_and_bypass.py b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_allow_access_from_public_custom_ips_and_bypass.py index c94e0ac92e9b..f8cc911d1240 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_allow_access_from_public_custom_ips_and_bypass.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_to_allow_access_from_public_custom_ips_and_bypass.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -50,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchUpdateServiceToAllowAccessFromPublicCustomIPsAndBypass.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/SearchUpdateServiceToAllowAccessFromPublicCustomIPsAndBypass.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 a3abf6e9afd8..076e291f7e9a 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -40,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchUpdateServiceToRemoveIdentity.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/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 6fd7ae2d2d68..22ec0ad0a0ea 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -43,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchUpdateServiceWithCmkEnforcement.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/SearchUpdateServiceWithCmkEnforcement.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_with_data_exfiltration.py b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_with_data_exfiltration.py index ddcd0eb78108..768c7c0a4fc3 100644 --- a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_with_data_exfiltration.py +++ b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_with_data_exfiltration.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -43,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchUpdateServiceWithDataExfiltration.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/SearchUpdateServiceWithDataExfiltration.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 index 6df99c9e1d03..66a67aa9b9f6 100644 --- 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -43,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchUpdateServiceWithSemanticSearch.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/SearchUpdateServiceWithSemanticSearch.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/search_update_service_with_sku.py b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_with_sku.py new file mode 100644 index 000000000000..b0692ac2da94 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_samples/search_update_service_with_sku.py @@ -0,0 +1,46 @@ +# 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_sku.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={ + "sku": {"name": "standard2"}, + "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/preview/2025-02-01-preview/examples/SearchUpdateServiceWithSku.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 2cb2f9d5406f..da715883a5e5 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.search import SearchManagementClient @@ -45,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/UpdatePrivateEndpointConnection.json +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/UpdatePrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/search/azure-mgmt-search/generated_samples/upgrade_search_service_to_latest_version.py b/sdk/search/azure-mgmt-search/generated_samples/upgrade_search_service_to_latest_version.py new file mode 100644 index 000000000000..4d634d225b00 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_samples/upgrade_search_service_to_latest_version.py @@ -0,0 +1,42 @@ +# 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 upgrade_search_service_to_latest_version.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.service.begin_upgrade( + resource_group_name="rg1", + search_service_name="mysearchservice", + ).result() + print(response) + + +# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/preview/2025-02-01-preview/examples/UpgradeSearchServiceToLatestVersion.json +if __name__ == "__main__": + main() diff --git a/sdk/search/azure-mgmt-search/generated_tests/conftest.py b/sdk/search/azure-mgmt-search/generated_tests/conftest.py new file mode 100644 index 000000000000..16cc48c352e7 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# 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. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + searchmanagement_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + searchmanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + searchmanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + searchmanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=searchmanagement_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=searchmanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=searchmanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=searchmanagement_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management.py new file mode 100644 index 000000000000..d0a2e3a0c5bd --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management.py @@ -0,0 +1,31 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagement(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_usage_by_subscription_sku(self, resource_group): + response = self.client.usage_by_subscription_sku( + location="str", + sku_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_admin_keys_operations.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_admin_keys_operations.py new file mode 100644 index 000000000000..7d019ac207fd --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_admin_keys_operations.py @@ -0,0 +1,44 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementAdminKeysOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_admin_keys_get(self, resource_group): + response = self.client.admin_keys.get( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_admin_keys_regenerate(self, resource_group): + response = self.client.admin_keys.regenerate( + resource_group_name=resource_group.name, + search_service_name="str", + key_kind="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_admin_keys_operations_async.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_admin_keys_operations_async.py new file mode 100644 index 000000000000..05e1acaaaabe --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_admin_keys_operations_async.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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search.aio import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementAdminKeysOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_admin_keys_get(self, resource_group): + response = await self.client.admin_keys.get( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_admin_keys_regenerate(self, resource_group): + response = await self.client.admin_keys.regenerate( + resource_group_name=resource_group.name, + search_service_name="str", + key_kind="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_async.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_async.py new file mode 100644 index 000000000000..18f8598bc4ca --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_async.py @@ -0,0 +1,32 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search.aio import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_usage_by_subscription_sku(self, resource_group): + response = await self.client.usage_by_subscription_sku( + location="str", + sku_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_network_security_perimeter_configurations_operations.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_network_security_perimeter_configurations_operations.py new file mode 100644 index 000000000000..9c868607cd8e --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_network_security_perimeter_configurations_operations.py @@ -0,0 +1,57 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementNetworkSecurityPerimeterConfigurationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_network_security_perimeter_configurations_list_by_service(self, resource_group): + response = self.client.network_security_perimeter_configurations.list_by_service( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_network_security_perimeter_configurations_get(self, resource_group): + response = self.client.network_security_perimeter_configurations.get( + resource_group_name=resource_group.name, + search_service_name="str", + nsp_config_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_network_security_perimeter_configurations_begin_reconcile(self, resource_group): + response = self.client.network_security_perimeter_configurations.begin_reconcile( + resource_group_name=resource_group.name, + search_service_name="str", + nsp_config_name="str", + api_version="2025-02-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_network_security_perimeter_configurations_operations_async.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_network_security_perimeter_configurations_operations_async.py new file mode 100644 index 000000000000..19fc7bdabcdb --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_network_security_perimeter_configurations_operations_async.py @@ -0,0 +1,60 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search.aio import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementNetworkSecurityPerimeterConfigurationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_network_security_perimeter_configurations_list_by_service(self, resource_group): + response = self.client.network_security_perimeter_configurations.list_by_service( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_network_security_perimeter_configurations_get(self, resource_group): + response = await self.client.network_security_perimeter_configurations.get( + resource_group_name=resource_group.name, + search_service_name="str", + nsp_config_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_network_security_perimeter_configurations_begin_reconcile(self, resource_group): + response = await ( + await self.client.network_security_perimeter_configurations.begin_reconcile( + resource_group_name=resource_group.name, + search_service_name="str", + nsp_config_name="str", + api_version="2025-02-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_offerings_operations.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_offerings_operations.py new file mode 100644 index 000000000000..954264d9a280 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_offerings_operations.py @@ -0,0 +1,29 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementOfferingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_offerings_list(self, resource_group): + response = self.client.offerings.list( + api_version="2025-02-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_offerings_operations_async.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_offerings_operations_async.py new file mode 100644 index 000000000000..736f3332d010 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_offerings_operations_async.py @@ -0,0 +1,30 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search.aio import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementOfferingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_offerings_list(self, resource_group): + response = self.client.offerings.list( + api_version="2025-02-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_operations.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_operations.py new file mode 100644 index 000000000000..65ab1be8bad0 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_operations.py @@ -0,0 +1,29 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operations_list(self, resource_group): + response = self.client.operations.list( + api_version="2025-02-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_operations_async.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_operations_async.py new file mode 100644 index 000000000000..bb81a4848c94 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_operations_async.py @@ -0,0 +1,30 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search.aio import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operations_list(self, resource_group): + response = self.client.operations.list( + api_version="2025-02-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_private_endpoint_connections_operations.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..a9175912c44e --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_private_endpoint_connections_operations.py @@ -0,0 +1,85 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_update(self, resource_group): + response = self.client.private_endpoint_connections.update( + resource_group_name=resource_group.name, + search_service_name="str", + private_endpoint_connection_name="str", + private_endpoint_connection={ + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "None", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, + "type": "str", + }, + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_get(self, resource_group): + response = self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + search_service_name="str", + private_endpoint_connection_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_delete(self, resource_group): + response = self.client.private_endpoint_connections.delete( + resource_group_name=resource_group.name, + search_service_name="str", + private_endpoint_connection_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_list_by_service(self, resource_group): + response = self.client.private_endpoint_connections.list_by_service( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_private_endpoint_connections_operations_async.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_private_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..530364e717eb --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_private_endpoint_connections_operations_async.py @@ -0,0 +1,86 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search.aio import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_update(self, resource_group): + response = await self.client.private_endpoint_connections.update( + resource_group_name=resource_group.name, + search_service_name="str", + private_endpoint_connection_name="str", + private_endpoint_connection={ + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "None", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, + "type": "str", + }, + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_get(self, resource_group): + response = await self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + search_service_name="str", + private_endpoint_connection_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_delete(self, resource_group): + response = await self.client.private_endpoint_connections.delete( + resource_group_name=resource_group.name, + search_service_name="str", + private_endpoint_connection_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_list_by_service(self, resource_group): + response = self.client.private_endpoint_connections.list_by_service( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_private_link_resources_operations.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_private_link_resources_operations.py new file mode 100644 index 000000000000..a8b333f2595d --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_private_link_resources_operations.py @@ -0,0 +1,31 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_resources_list_supported(self, resource_group): + response = self.client.private_link_resources.list_supported( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_private_link_resources_operations_async.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_private_link_resources_operations_async.py new file mode 100644 index 000000000000..1db5140fed86 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_private_link_resources_operations_async.py @@ -0,0 +1,32 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search.aio import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_resources_list_supported(self, resource_group): + response = self.client.private_link_resources.list_supported( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_query_keys_operations.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_query_keys_operations.py new file mode 100644 index 000000000000..5224dd513560 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_query_keys_operations.py @@ -0,0 +1,57 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementQueryKeysOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_query_keys_create(self, resource_group): + response = self.client.query_keys.create( + resource_group_name=resource_group.name, + search_service_name="str", + name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_query_keys_list_by_search_service(self, resource_group): + response = self.client.query_keys.list_by_search_service( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_query_keys_delete(self, resource_group): + response = self.client.query_keys.delete( + resource_group_name=resource_group.name, + search_service_name="str", + key="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_query_keys_operations_async.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_query_keys_operations_async.py new file mode 100644 index 000000000000..2c297a1f4427 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_query_keys_operations_async.py @@ -0,0 +1,58 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search.aio import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementQueryKeysOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_query_keys_create(self, resource_group): + response = await self.client.query_keys.create( + resource_group_name=resource_group.name, + search_service_name="str", + name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_query_keys_list_by_search_service(self, resource_group): + response = self.client.query_keys.list_by_search_service( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_query_keys_delete(self, resource_group): + response = await self.client.query_keys.delete( + resource_group_name=resource_group.name, + search_service_name="str", + key="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_service_operations.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_service_operations.py new file mode 100644 index 000000000000..dbceb47babce --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_service_operations.py @@ -0,0 +1,31 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementServiceOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_service_begin_upgrade(self, resource_group): + response = self.client.service.begin_upgrade( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_service_operations_async.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_service_operations_async.py new file mode 100644 index 000000000000..dd9978a96a25 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_service_operations_async.py @@ -0,0 +1,34 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search.aio import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementServiceOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_service_begin_upgrade(self, resource_group): + response = await ( + await self.client.service.begin_upgrade( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_services_operations.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_services_operations.py new file mode 100644 index 000000000000..dce36f07767e --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_services_operations.py @@ -0,0 +1,244 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementServicesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_services_begin_create_or_update(self, resource_group): + response = self.client.services.begin_create_or_update( + resource_group_name=resource_group.name, + search_service_name="str", + service={ + "location": "str", + "authOptions": {"aadOrApiKey": {"aadAuthFailureMode": "str"}, "apiKeyOnly": {}}, + "computeType": "str", + "disableLocalAuth": bool, + "disabledDataExfiltrationOptions": ["str"], + "eTag": "str", + "encryptionWithCmk": {"encryptionComplianceStatus": "str", "enforcement": "str"}, + "endpoint": "str", + "hostingMode": "default", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "networkRuleSet": {"bypass": "str", "ipRules": [{"value": "str"}]}, + "partitionCount": 1, + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "None", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "enabled", + "replicaCount": 1, + "semanticSearch": "str", + "serviceUpgradeDate": "2020-02-20 00:00:00", + "sharedPrivateLinkResources": [ + { + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "requestMessage": "str", + "resourceRegion": "str", + "status": "str", + }, + "type": "str", + } + ], + "sku": {"name": "str"}, + "status": "str", + "statusDetails": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "upgradeAvailable": bool, + }, + api_version="2025-02-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_services_update(self, resource_group): + response = self.client.services.update( + resource_group_name=resource_group.name, + search_service_name="str", + service={ + "authOptions": {"aadOrApiKey": {"aadAuthFailureMode": "str"}, "apiKeyOnly": {}}, + "computeType": "str", + "disableLocalAuth": bool, + "disabledDataExfiltrationOptions": ["str"], + "eTag": "str", + "encryptionWithCmk": {"encryptionComplianceStatus": "str", "enforcement": "str"}, + "endpoint": "str", + "hostingMode": "default", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "location": "str", + "name": "str", + "networkRuleSet": {"bypass": "str", "ipRules": [{"value": "str"}]}, + "partitionCount": 1, + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "None", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "enabled", + "replicaCount": 1, + "semanticSearch": "str", + "serviceUpgradeDate": "2020-02-20 00:00:00", + "sharedPrivateLinkResources": [ + { + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "requestMessage": "str", + "resourceRegion": "str", + "status": "str", + }, + "type": "str", + } + ], + "sku": {"name": "str"}, + "status": "str", + "statusDetails": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "upgradeAvailable": bool, + }, + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_services_get(self, resource_group): + response = self.client.services.get( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_services_delete(self, resource_group): + response = self.client.services.delete( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_services_list_by_resource_group(self, resource_group): + response = self.client.services.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2025-02-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_services_list_by_subscription(self, resource_group): + response = self.client.services.list_by_subscription( + api_version="2025-02-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_services_check_name_availability(self, resource_group): + response = self.client.services.check_name_availability( + name="str", + api_version="2025-02-01-preview", + type="searchServices", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_services_operations_async.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_services_operations_async.py new file mode 100644 index 000000000000..bfbccba7541f --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_services_operations_async.py @@ -0,0 +1,247 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search.aio import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementServicesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_services_begin_create_or_update(self, resource_group): + response = await ( + await self.client.services.begin_create_or_update( + resource_group_name=resource_group.name, + search_service_name="str", + service={ + "location": "str", + "authOptions": {"aadOrApiKey": {"aadAuthFailureMode": "str"}, "apiKeyOnly": {}}, + "computeType": "str", + "disableLocalAuth": bool, + "disabledDataExfiltrationOptions": ["str"], + "eTag": "str", + "encryptionWithCmk": {"encryptionComplianceStatus": "str", "enforcement": "str"}, + "endpoint": "str", + "hostingMode": "default", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "networkRuleSet": {"bypass": "str", "ipRules": [{"value": "str"}]}, + "partitionCount": 1, + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "None", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "enabled", + "replicaCount": 1, + "semanticSearch": "str", + "serviceUpgradeDate": "2020-02-20 00:00:00", + "sharedPrivateLinkResources": [ + { + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "requestMessage": "str", + "resourceRegion": "str", + "status": "str", + }, + "type": "str", + } + ], + "sku": {"name": "str"}, + "status": "str", + "statusDetails": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "upgradeAvailable": bool, + }, + api_version="2025-02-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_services_update(self, resource_group): + response = await self.client.services.update( + resource_group_name=resource_group.name, + search_service_name="str", + service={ + "authOptions": {"aadOrApiKey": {"aadAuthFailureMode": "str"}, "apiKeyOnly": {}}, + "computeType": "str", + "disableLocalAuth": bool, + "disabledDataExfiltrationOptions": ["str"], + "eTag": "str", + "encryptionWithCmk": {"encryptionComplianceStatus": "str", "enforcement": "str"}, + "endpoint": "str", + "hostingMode": "default", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "location": "str", + "name": "str", + "networkRuleSet": {"bypass": "str", "ipRules": [{"value": "str"}]}, + "partitionCount": 1, + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "None", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "enabled", + "replicaCount": 1, + "semanticSearch": "str", + "serviceUpgradeDate": "2020-02-20 00:00:00", + "sharedPrivateLinkResources": [ + { + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "requestMessage": "str", + "resourceRegion": "str", + "status": "str", + }, + "type": "str", + } + ], + "sku": {"name": "str"}, + "status": "str", + "statusDetails": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "upgradeAvailable": bool, + }, + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_services_get(self, resource_group): + response = await self.client.services.get( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_services_delete(self, resource_group): + response = await self.client.services.delete( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_services_list_by_resource_group(self, resource_group): + response = self.client.services.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2025-02-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_services_list_by_subscription(self, resource_group): + response = self.client.services.list_by_subscription( + api_version="2025-02-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_services_check_name_availability(self, resource_group): + response = await self.client.services.check_name_availability( + name="str", + api_version="2025-02-01-preview", + type="searchServices", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_shared_private_link_resources_operations.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_shared_private_link_resources_operations.py new file mode 100644 index 000000000000..1d8d15d74c2d --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_shared_private_link_resources_operations.py @@ -0,0 +1,83 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementSharedPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_shared_private_link_resources_begin_create_or_update(self, resource_group): + response = self.client.shared_private_link_resources.begin_create_or_update( + resource_group_name=resource_group.name, + search_service_name="str", + shared_private_link_resource_name="str", + shared_private_link_resource={ + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "requestMessage": "str", + "resourceRegion": "str", + "status": "str", + }, + "type": "str", + }, + api_version="2025-02-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_shared_private_link_resources_get(self, resource_group): + response = self.client.shared_private_link_resources.get( + resource_group_name=resource_group.name, + search_service_name="str", + shared_private_link_resource_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_shared_private_link_resources_begin_delete(self, resource_group): + response = self.client.shared_private_link_resources.begin_delete( + resource_group_name=resource_group.name, + search_service_name="str", + shared_private_link_resource_name="str", + api_version="2025-02-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_shared_private_link_resources_list_by_service(self, resource_group): + response = self.client.shared_private_link_resources.list_by_service( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_shared_private_link_resources_operations_async.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_shared_private_link_resources_operations_async.py new file mode 100644 index 000000000000..ed1fb76ee5e9 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_shared_private_link_resources_operations_async.py @@ -0,0 +1,88 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search.aio import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementSharedPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_shared_private_link_resources_begin_create_or_update(self, resource_group): + response = await ( + await self.client.shared_private_link_resources.begin_create_or_update( + resource_group_name=resource_group.name, + search_service_name="str", + shared_private_link_resource_name="str", + shared_private_link_resource={ + "id": "str", + "name": "str", + "properties": { + "groupId": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "requestMessage": "str", + "resourceRegion": "str", + "status": "str", + }, + "type": "str", + }, + api_version="2025-02-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_shared_private_link_resources_get(self, resource_group): + response = await self.client.shared_private_link_resources.get( + resource_group_name=resource_group.name, + search_service_name="str", + shared_private_link_resource_name="str", + api_version="2025-02-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_shared_private_link_resources_begin_delete(self, resource_group): + response = await ( + await self.client.shared_private_link_resources.begin_delete( + resource_group_name=resource_group.name, + search_service_name="str", + shared_private_link_resource_name="str", + api_version="2025-02-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_shared_private_link_resources_list_by_service(self, resource_group): + response = self.client.shared_private_link_resources.list_by_service( + resource_group_name=resource_group.name, + search_service_name="str", + api_version="2025-02-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_usages_operations.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_usages_operations.py new file mode 100644 index 000000000000..cff1765e1910 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_usages_operations.py @@ -0,0 +1,30 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementUsagesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_usages_list_by_subscription(self, resource_group): + response = self.client.usages.list_by_subscription( + location="str", + api_version="2025-02-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/generated_tests/test_search_management_usages_operations_async.py b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_usages_operations_async.py new file mode 100644 index 000000000000..873981ba4766 --- /dev/null +++ b/sdk/search/azure-mgmt-search/generated_tests/test_search_management_usages_operations_async.py @@ -0,0 +1,31 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.search.aio import SearchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSearchManagementUsagesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SearchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_usages_list_by_subscription(self, resource_group): + response = self.client.usages.list_by_subscription( + location="str", + api_version="2025-02-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/search/azure-mgmt-search/setup.py b/sdk/search/azure-mgmt-search/setup.py index 3dd1d3586584..9d3d278b3aab 100644 --- a/sdk/search/azure-mgmt-search/setup.py +++ b/sdk/search/azure-mgmt-search/setup.py @@ -75,6 +75,7 @@ }, install_requires=[ "isodate>=0.6.1", + "typing-extensions>=4.6.0", "azure-common>=1.1", "azure-mgmt-core>=1.3.2", ],