From a6899a3077453cb0507120a8985291ebf8341339 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 9 Jun 2023 01:06:55 +0000 Subject: [PATCH] CodeGen from PR 24201 in Azure/azure-rest-api-specs Add new PES SKU to Healthbot (#24201) * create new api version * Add PES SKU name * update examples api-version versions reference * fix api version * Fix default version * add 201 response header example * fix example --------- Co-authored-by: Arie Schwartzman Co-authored-by: Arie Schwartzman --- sdk/healthbot/azure-mgmt-healthbot/_meta.json | 6 +- .../azure/mgmt/healthbot/__init__.py | 2 +- .../azure/mgmt/healthbot/_configuration.py | 15 +- .../mgmt/healthbot/_health_bot_mgmt_client.py | 17 +- .../azure/mgmt/healthbot/_serialization.py | 180 ++++---- .../azure/mgmt/healthbot/_vendor.py | 5 +- .../azure/mgmt/healthbot/_version.py | 2 +- .../azure/mgmt/healthbot/aio/__init__.py | 2 +- .../mgmt/healthbot/aio/_configuration.py | 10 +- .../healthbot/aio/_health_bot_mgmt_client.py | 10 +- .../mgmt/healthbot/aio/operations/__init__.py | 2 +- .../aio/operations/_bots_operations.py | 401 +++++++++------- .../healthbot/aio/operations/_operations.py | 24 +- .../azure/mgmt/healthbot/models/__init__.py | 2 +- .../models/_health_bot_mgmt_client_enums.py | 1 + .../mgmt/healthbot/models/_models_py3.py | 66 +-- .../mgmt/healthbot/operations/__init__.py | 2 +- .../healthbot/operations/_bots_operations.py | 434 +++++++++++------- .../mgmt/healthbot/operations/_operations.py | 26 +- .../generated_samples/get_operations.py | 2 +- .../list_bots_by_resource_group.py | 2 +- .../list_bots_by_subscription.py | 2 +- .../{bot_list_secrets.py => list_secrets.py} | 4 +- ...secret.py => regenerate_api_jwt_secret.py} | 4 +- ...bot_create.py => resource_creation_put.py} | 4 +- ..._delete.py => resource_deletion_delete.py} | 7 +- .../generated_samples/resource_info_get.py | 2 +- ...bot_update.py => resource_update_patch.py} | 8 +- 28 files changed, 701 insertions(+), 541 deletions(-) rename sdk/healthbot/azure-mgmt-healthbot/generated_samples/{bot_list_secrets.py => list_secrets.py} (93%) rename sdk/healthbot/azure-mgmt-healthbot/generated_samples/{bot_regenerate_api_jwt_secret.py => regenerate_api_jwt_secret.py} (93%) rename sdk/healthbot/azure-mgmt-healthbot/generated_samples/{bot_create.py => resource_creation_put.py} (95%) rename sdk/healthbot/azure-mgmt-healthbot/generated_samples/{bot_delete.py => resource_deletion_delete.py} (90%) rename sdk/healthbot/azure-mgmt-healthbot/generated_samples/{bot_update.py => resource_update_patch.py} (90%) diff --git a/sdk/healthbot/azure-mgmt-healthbot/_meta.json b/sdk/healthbot/azure-mgmt-healthbot/_meta.json index 59f6422cae98a..12fb8a8326417 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/_meta.json +++ b/sdk/healthbot/azure-mgmt-healthbot/_meta.json @@ -1,11 +1,11 @@ { - "commit": "e82a24def11ffc98cc263884f9f1742c99f2df5e", + "commit": "1cc94725e3d38571fdf10d5d69b89a2f07ed8709", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.2", "use": [ - "@autorest/python@6.2.1", + "@autorest/python@6.5.0", "@autorest/modelerfour@4.24.3" ], - "autorest_command": "autorest specification/healthbot/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.2.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/healthbot/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.5.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/healthbot/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/__init__.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/__init__.py index bfc96e4fb4c49..e1b2d1501349c 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/__init__.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/__init__.py @@ -13,7 +13,7 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_configuration.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_configuration.py index 5e00e3a228089..efc3fc49d1241 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_configuration.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -35,14 +29,14 @@ class HealthBotMgmtClientConfiguration(Configuration): # pylint: disable=too-ma :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Azure Subscription ID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-08-08". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(HealthBotMgmtClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-08-08") # type: Literal["2022-08-08"] + api_version: str = kwargs.pop("api_version", "2023-05-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -56,10 +50,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-healthbot/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_health_bot_mgmt_client.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_health_bot_mgmt_client.py index acd5114361c4c..5e6c02f3fe713 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_health_bot_mgmt_client.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_health_bot_mgmt_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from ._configuration import HealthBotMgmtClientConfiguration from ._serialization import Deserializer, Serializer from .operations import BotsOperations, Operations @@ -37,7 +37,7 @@ class HealthBotMgmtClient: # pylint: disable=client-accepts-api-version-keyword :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-08-08". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -54,9 +54,9 @@ def __init__( self._config = HealthBotMgmtClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -85,15 +85,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> HealthBotMgmtClient + def __enter__(self) -> "HealthBotMgmtClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_serialization.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_serialization.py index 7c1dedb5133d3..842ae727fbbce 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_serialization.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_serialization.py @@ -25,6 +25,7 @@ # -------------------------------------------------------------------------- # pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode import calendar @@ -37,23 +38,38 @@ import re import sys import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) try: from urllib import quote # type: ignore except ImportError: - from urllib.parse import quote # type: ignore + from urllib.parse import quote import xml.etree.ElementTree as ET -import isodate - -from typing import Dict, Any, cast, TYPE_CHECKING +import isodate # type: ignore from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.serialization import NULL as AzureCoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -if TYPE_CHECKING: - from typing import Optional, Union, AnyStr, IO, Mapping +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] class RawDeserializer: @@ -65,8 +81,7 @@ class RawDeserializer: CONTEXT_NAME = "deserialized_data" @classmethod - def deserialize_from_text(cls, data, content_type=None): - # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: """Decode data according to content-type. Accept a stream of data as well, but will be load at once in memory for now. @@ -132,8 +147,7 @@ def _json_attemp(data): raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod - def deserialize_from_http_generics(cls, body_bytes, headers): - # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: """Deserialize from HTTP response. Use bytes and headers to NOT use any requests/aiohttp or whatever @@ -160,8 +174,8 @@ def deserialize_from_http_generics(cls, body_bytes, headers): basestring # type: ignore unicode_str = unicode # type: ignore except NameError: - basestring = str # type: ignore - unicode_str = str # type: ignore + basestring = str + unicode_str = str _LOGGER = logging.getLogger(__name__) @@ -188,7 +202,7 @@ def dst(self, dt): try: - from datetime import timezone as _FixedOffset + from datetime import timezone as _FixedOffset # type: ignore except ImportError: # Python 2.7 class _FixedOffset(datetime.tzinfo): # type: ignore @@ -219,7 +233,7 @@ def __getinitargs__(self): try: from datetime import timezone - TZ_UTC = timezone.utc # type: ignore + TZ_UTC = timezone.utc except ImportError: TZ_UTC = UTC() # type: ignore @@ -276,12 +290,12 @@ class Model(object): serialization and deserialization. """ - _subtype_map = {} # type: Dict[str, Dict[str, Any]] - _attribute_map = {} # type: Dict[str, Dict[str, Any]] - _validation = {} # type: Dict[str, Dict[str, Any]] + _subtype_map: Dict[str, Dict[str, Any]] = {} + _attribute_map: Dict[str, Dict[str, Any]] = {} + _validation: Dict[str, Dict[str, Any]] = {} - def __init__(self, **kwargs): - self.additional_properties = {} + def __init__(self, **kwargs: Any) -> None: + self.additional_properties: Dict[str, Any] = {} for k in kwargs: 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__) @@ -290,27 +304,27 @@ def __init__(self, **kwargs): else: setattr(self, k, kwargs[k]) - def __eq__(self, other): + def __eq__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False - def __ne__(self, other): + def __ne__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" return not self.__eq__(other) - def __str__(self): + def __str__(self) -> str: return str(self.__dict__) @classmethod - def enable_additional_properties_sending(cls): + def enable_additional_properties_sending(cls) -> None: cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} @classmethod - def is_xml_model(cls): + def is_xml_model(cls) -> bool: try: - cls._xml_map + cls._xml_map # type: ignore except AttributeError: return False return True @@ -319,13 +333,13 @@ def is_xml_model(cls): def _create_xml_node(cls): """Create XML node.""" try: - xml_map = cls._xml_map + xml_map = cls._xml_map # type: ignore except AttributeError: xml_map = {} return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - def serialize(self, keep_readonly=False, **kwargs): + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: """Return the JSON that would be sent to azure from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -339,8 +353,13 @@ def serialize(self, keep_readonly=False, **kwargs): serializer = Serializer(self._infer_class_models()) return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) - def as_dict(self, keep_readonly=True, key_transformer=attribute_transformer, **kwargs): - """Return a dict that can be JSONify using json.dump. + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. Advanced usage might optionally use a callback as parameter: @@ -387,7 +406,7 @@ def _infer_class_models(cls): return client_models @classmethod - def deserialize(cls, data, content_type=None): + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. @@ -399,7 +418,12 @@ def deserialize(cls, data, content_type=None): return deserializer(cls.__name__, data, content_type=content_type) @classmethod - def from_dict(cls, data, key_extractors=None, content_type=None): + def from_dict( + cls: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: """Parse a dict using given key extractor return a model. By default consider key @@ -412,8 +436,8 @@ def from_dict(cls, data, key_extractors=None, content_type=None): :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( - [ + deserializer.key_extractors = ( # type: ignore + [ # type: ignore attribute_key_case_insensitive_extractor, rest_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, @@ -453,7 +477,7 @@ def _classify(cls, response, objects): return cls flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) try: - return objects[flatten_mapping_type[subtype_value]] + return objects[flatten_mapping_type[subtype_value]] # type: ignore except KeyError: _LOGGER.warning( "Subtype value %s has no mapping, use base class %s.", @@ -521,7 +545,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -537,7 +561,7 @@ def __init__(self, classes=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -605,14 +629,14 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): - serialized.text = new_attr + serialized.text = new_attr # type: ignore continue if isinstance(new_attr, list): - serialized.extend(new_attr) + 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 "name" not in getattr(orig_attr, "_xml_map", {}): @@ -621,23 +645,22 @@ def _serialize(self, target_obj, data_type=None, **kwargs): new_attr.tag = "}".join([splitted_tag[0], xml_name]) else: new_attr.tag = xml_name - serialized.append(new_attr) + serialized.append(new_attr) # type: ignore else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) local_node.text = unicode_str(new_attr) - serialized.append(local_node) + serialized.append(local_node) # type: ignore else: # JSON - for k in reversed(keys): - unflattened = {k: new_attr} - new_attr = unflattened + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} _new_attr = new_attr _serialized = serialized - for k in keys: + for k in keys: # type: ignore if k not in _serialized: - _serialized.update(_new_attr) - _new_attr = _new_attr[k] + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] except ValueError: continue @@ -659,8 +682,8 @@ def body(self, data, data_type, **kwargs): """ # Just in case this is a dict - internal_data_type = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type, None) + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) try: is_xml_model_serialization = kwargs["is_xml"] except KeyError: @@ -675,7 +698,7 @@ def body(self, data, data_type, **kwargs): # We're not able to deal with additional properties for now. deserializer.additional_properties_detection = False if is_xml_model_serialization: - deserializer.key_extractors = [ + deserializer.key_extractors = [ # type: ignore attribute_key_case_insensitive_extractor, ] else: @@ -780,6 +803,8 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: + if data is AzureCoreNull: + return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -843,7 +868,7 @@ def serialize_unicode(cls, data): pass try: - if isinstance(data, unicode): + if isinstance(data, unicode): # type: ignore # Don't change it, JSON and XML ElementTree are totally able # to serialize correctly u'' strings return data @@ -1001,10 +1026,10 @@ def serialize_enum(attr, enum_obj=None): except AttributeError: result = attr try: - enum_obj(result) + enum_obj(result) # type: ignore return result except ValueError: - for enum_value in enum_obj: + 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}" @@ -1164,7 +1189,8 @@ def rest_key_extractor(attr, attr_desc, data): working_data = data while "." in key: - dict_keys = _FLATTEN.split(key) + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1245,7 +1271,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1269,7 +1295,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): @@ -1335,7 +1361,7 @@ class Deserializer(object): 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}]?") - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1355,7 +1381,7 @@ def __init__(self, classes=None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1416,7 +1442,7 @@ def _deserialize(self, target_obj, data): if data is None: return data try: - attributes = response._attribute_map + attributes = response._attribute_map # type: ignore d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1444,7 +1470,7 @@ def _deserialize(self, target_obj, data): value = self.deserialize_data(raw_value, attr_desc["type"]) d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name + msg = "Unable to deserialize to object: " + class_name # type: ignore raise_with_traceback(DeserializationError, msg, err) else: additional_properties = self._build_additional_properties(attributes, data) @@ -1474,7 +1500,7 @@ def _classify_target(self, target, data): Once classification has been determined, initialize object. :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. """ if target is None: return None, None @@ -1489,7 +1515,7 @@ def _classify_target(self, target, data): target = target._classify(data, self.dependencies) except AttributeError: pass # Target is not a Model, no classify - return target, target.__class__.__name__ + return target, target.__class__.__name__ # type: ignore def failsafe_deserialize(self, target_obj, data, content_type=None): """Ignores any errors encountered in deserialization, @@ -1499,7 +1525,7 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): a deserialization error. :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. """ try: @@ -1543,7 +1569,7 @@ def _unpack_content(raw_data, content_type=None): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data def _instantiate_model(self, response, attrs, additional_properties=None): @@ -1565,7 +1591,7 @@ def _instantiate_model(self, response, attrs, additional_properties=None): response_obj.additional_properties = additional_properties return response_obj except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore raise DeserializationError(msg + str(err)) else: try: @@ -1747,7 +1773,7 @@ def deserialize_unicode(data): # Consider this is real string try: - if isinstance(data, unicode): + if isinstance(data, unicode): # type: ignore return data except NameError: return str(data) @@ -1798,7 +1824,7 @@ def deserialize_bytearray(attr): """ if isinstance(attr, ET.Element): attr = attr.text - return bytearray(b64decode(attr)) + return bytearray(b64decode(attr)) # type: ignore @staticmethod def deserialize_base64(attr): @@ -1810,8 +1836,8 @@ def deserialize_base64(attr): """ if isinstance(attr, ET.Element): attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) - attr = attr + padding + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore encoded = attr.replace("-", "+").replace("_", "/") return b64decode(encoded) @@ -1826,7 +1852,7 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) + return decimal.Decimal(attr) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) raise_with_traceback(DeserializationError, msg, err) @@ -1841,7 +1867,7 @@ def deserialize_long(attr): """ if isinstance(attr, ET.Element): attr = attr.text - return _long_type(attr) + return _long_type(attr) # type: ignore @staticmethod def deserialize_duration(attr): @@ -1871,7 +1897,7 @@ def deserialize_date(attr): """ if isinstance(attr, ET.Element): attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. return isodate.parse_date(attr, defaultmonth=None, defaultday=None) @@ -1886,7 +1912,7 @@ def deserialize_time(attr): """ if isinstance(attr, ET.Element): attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) return isodate.parse_time(attr) @@ -1901,7 +1927,7 @@ def deserialize_rfc(attr): if isinstance(attr, ET.Element): attr = attr.text try: - parsed_date = email.utils.parsedate_tz(attr) + parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) @@ -1924,7 +1950,7 @@ def deserialize_iso(attr): if isinstance(attr, ET.Element): attr = attr.text try: - attr = attr.upper() + attr = attr.upper() # type: ignore match = Deserializer.valid_date.match(attr) if not match: raise ValueError("Invalid datetime string: " + attr) @@ -1960,7 +1986,7 @@ def deserialize_unix(attr): :raises: DeserializationError if format invalid """ if isinstance(attr, ET.Element): - attr = int(attr.text) + attr = int(attr.text) # type: ignore try: date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_vendor.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_vendor.py index 9aad73fc743e7..bd0df84f5319f 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_vendor.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_version.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_version.py index dfa6ee022f154..e5754a47ce68f 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_version.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b2" +VERSION = "1.0.0b1" diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/__init__.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/__init__.py index a9d6ae4babe6b..b4b424c68dd23 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/__init__.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/__init__.py @@ -10,7 +10,7 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/_configuration.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/_configuration.py index a144a6b462c40..46416020a9e08 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/_configuration.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -35,14 +29,14 @@ class HealthBotMgmtClientConfiguration(Configuration): # pylint: disable=too-ma :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Azure Subscription ID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-08-08". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(HealthBotMgmtClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-08-08") # type: Literal["2022-08-08"] + api_version: str = kwargs.pop("api_version", "2023-05-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/_health_bot_mgmt_client.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/_health_bot_mgmt_client.py index b527a6a075527..144637a48e38e 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/_health_bot_mgmt_client.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/_health_bot_mgmt_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import HealthBotMgmtClientConfiguration from .operations import BotsOperations, Operations @@ -37,7 +37,7 @@ class HealthBotMgmtClient: # pylint: disable=client-accepts-api-version-keyword :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-08-08". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -54,9 +54,9 @@ def __init__( self._config = HealthBotMgmtClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -92,5 +92,5 @@ async def __aenter__(self) -> "HealthBotMgmtClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/operations/__init__.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/operations/__init__.py index 6375fff9b1ba1..16455565e5867 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/operations/__init__.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/operations/__init__.py @@ -10,7 +10,7 @@ from ._operations import Operations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/operations/_bots_operations.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/operations/_bots_operations.py index 88b9a99230a14..e8487e0856d10 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/operations/_bots_operations.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/operations/_bots_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -42,10 +42,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,16 +79,14 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthBot] + 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.HealthBot] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "HealthBot") @@ -110,10 +104,11 @@ async def _create_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -130,11 +125,13 @@ async def _create_initial( deserialized = self._deserialize("HealthBot", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" + } @overload async def begin_create( @@ -220,7 +217,7 @@ async def begin_create( :param bot_name: The name of the Bot resource. Required. :type bot_name: str :param parameters: The parameters to provide for the created Azure Health Bot. Is either a - model type or a IO type. Required. + HealthBot type or a IO type. Required. :type parameters: ~azure.mgmt.healthbot.models.HealthBot or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -241,16 +238,14 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthBot] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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.HealthBot] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_initial( # type: ignore + raw_result = await self._create_initial( resource_group_name=resource_group_name, bot_name=bot_name, parameters=parameters, @@ -270,10 +265,10 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) # type: AsyncPollingMethod + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -285,9 +280,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" + } @distributed_trace_async async def get(self, resource_group_name: str, bot_name: str, **kwargs: Any) -> _models.HealthBot: @@ -314,10 +311,8 @@ async def get(self, resource_group_name: str, bot_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthBot] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.HealthBot] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -329,10 +324,11 @@ async def get(self, resource_group_name: str, bot_name: str, **kwargs: Any) -> _ params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -349,10 +345,84 @@ async def get(self, resource_group_name: str, bot_name: str, **kwargs: Any) -> _ return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" + } + + async def _update_initial( + self, + resource_group_name: str, + bot_name: str, + parameters: Union[_models.HealthBotUpdateParameters, IO], + **kwargs: Any + ) -> _models.HealthBot: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.HealthBot] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "HealthBotUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + bot_name=bot_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("HealthBot", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("HealthBot", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" + } @overload - async def update( + async def begin_update( self, resource_group_name: str, bot_name: str, @@ -360,7 +430,7 @@ async def update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.HealthBot: + ) -> AsyncLROPoller[_models.HealthBot]: """Patch a HealthBot. :param resource_group_name: The name of the Bot resource group in the user subscription. @@ -374,13 +444,21 @@ async def update( Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HealthBot or the result of cls(response) - :rtype: ~azure.mgmt.healthbot.models.HealthBot + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either HealthBot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.healthbot.models.HealthBot] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( + async def begin_update( self, resource_group_name: str, bot_name: str, @@ -388,7 +466,7 @@ async def update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.HealthBot: + ) -> AsyncLROPoller[_models.HealthBot]: """Patch a HealthBot. :param resource_group_name: The name of the Bot resource group in the user subscription. @@ -402,19 +480,27 @@ async def update( Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HealthBot or the result of cls(response) - :rtype: ~azure.mgmt.healthbot.models.HealthBot + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either HealthBot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.healthbot.models.HealthBot] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( + async def begin_update( self, resource_group_name: str, bot_name: str, parameters: Union[_models.HealthBotUpdateParameters, IO], **kwargs: Any - ) -> _models.HealthBot: + ) -> AsyncLROPoller[_models.HealthBot]: """Patch a HealthBot. :param resource_group_name: The name of the Bot resource group in the user subscription. @@ -423,79 +509,71 @@ async def update( :param bot_name: The name of the Bot resource. Required. :type bot_name: str :param parameters: The parameters to provide for the required Azure Health Bot. Is either a - model type or a IO type. Required. + HealthBotUpdateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.healthbot.models.HealthBotUpdateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HealthBot or the result of cls(response) - :rtype: ~azure.mgmt.healthbot.models.HealthBot + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either HealthBot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.healthbot.models.HealthBot] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthBot] - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "HealthBotUpdateParameters") - - request = build_update_request( - resource_group_name=resource_group_name, - bot_name=bot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("HealthBot", pipeline_response) + 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.HealthBot] = 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._update_initial( + resource_group_name=resource_group_name, + bot_name=bot_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - if response.status_code == 201: + def get_long_running_output(pipeline_response): deserialized = self._deserialize("HealthBot", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, bot_name: str, **kwargs: Any @@ -511,10 +589,8 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -526,10 +602,11 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -542,7 +619,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" + } @distributed_trace_async async def begin_delete(self, resource_group_name: str, bot_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -568,13 +647,11 @@ async def begin_delete(self, resource_group_name: str, bot_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -592,7 +669,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -604,9 +681,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" + } @distributed_trace_async async def list_secrets( @@ -635,10 +714,8 @@ async def list_secrets( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthBotKeysResponse] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.HealthBotKeysResponse] = kwargs.pop("cls", None) request = build_list_secrets_request( resource_group_name=resource_group_name, @@ -650,10 +727,11 @@ async def list_secrets( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -670,7 +748,9 @@ async def list_secrets( return deserialized - list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/listSecrets"} # type: ignore + list_secrets.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/listSecrets" + } @distributed_trace_async async def regenerate_api_jwt_secret( @@ -699,10 +779,8 @@ async def regenerate_api_jwt_secret( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthBotKey] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.HealthBotKey] = kwargs.pop("cls", None) request = build_regenerate_api_jwt_secret_request( resource_group_name=resource_group_name, @@ -714,10 +792,11 @@ async def regenerate_api_jwt_secret( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -734,7 +813,9 @@ async def regenerate_api_jwt_secret( return deserialized - regenerate_api_jwt_secret.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/regenerateApiJwtSecret"} # type: ignore + regenerate_api_jwt_secret.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/regenerateApiJwtSecret" + } @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.HealthBot"]: @@ -751,10 +832,8 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.BotResponseList] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BotResponseList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -776,7 +855,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -792,7 +871,7 @@ def prepare_request(next_link=None): "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) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -800,14 +879,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("BotResponseList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -820,7 +900,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots" + } @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.HealthBot"]: @@ -834,10 +916,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.HealthBot"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.BotResponseList] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BotResponseList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -858,7 +938,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -874,7 +954,7 @@ def prepare_request(next_link=None): "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) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -882,14 +962,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("BotResponseList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -902,4 +983,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HealthBot/healthBots"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HealthBot/healthBots"} diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/operations/_operations.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/operations/_operations.py index 7e18a7d1ccd9c..e5293922252fe 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/operations/_operations.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,10 +64,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDetail"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableOperations] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AvailableOperations] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -92,7 +85,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -108,7 +101,7 @@ def prepare_request(next_link=None): "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) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -116,14 +109,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AvailableOperations", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -136,4 +130,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.HealthBot/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.HealthBot/operations"} diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/models/__init__.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/models/__init__.py index 65b08d6297e89..c7e0ce672fb0f 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/models/__init__.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/models/__init__.py @@ -31,7 +31,7 @@ from ._health_bot_mgmt_client_enums import ResourceIdentityType from ._health_bot_mgmt_client_enums import SkuName from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/models/_health_bot_mgmt_client_enums.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/models/_health_bot_mgmt_client_enums.py index 3f4292120b4de..e1f9f5eb98610 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/models/_health_bot_mgmt_client_enums.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/models/_health_bot_mgmt_client_enums.py @@ -37,3 +37,4 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): F0 = "F0" S1 = "S1" C0 = "C0" + PES = "PES" diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/models/_models_py3.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/models/_models_py3.py index 2d352e7ea6402..868ea66363724 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/models/_models_py3.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/models/_models_py3.py @@ -40,8 +40,8 @@ class AvailableOperations(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.OperationDetail"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, *, value: Optional[List["_models.OperationDetail"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: Collection of available operation details. :paramtype value: list[~azure.mgmt.healthbot.models.OperationDetail] @@ -75,7 +75,7 @@ class BotResponseList(_serialization.Model): "value": {"key": "value", "type": "[HealthBot]"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.next_link = None @@ -93,7 +93,7 @@ class Error(_serialization.Model): "error": {"key": "error", "type": "ErrorError"}, } - def __init__(self, *, error: Optional["_models.ErrorError"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorError"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.healthbot.models.ErrorError @@ -123,7 +123,7 @@ class ErrorAdditionalInfo(_serialization.Model): "info": {"key": "info", "type": "object"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None @@ -163,7 +163,7 @@ class ErrorError(_serialization.Model): "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None @@ -202,7 +202,7 @@ class Resource(_serialization.Model): "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None @@ -249,7 +249,7 @@ class TrackedResource(Resource): "location": {"key": "location", "type": "str"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -317,8 +317,8 @@ def __init__( tags: Optional[Dict[str, str]] = None, identity: Optional["_models.Identity"] = None, properties: Optional["_models.HealthBotProperties"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -351,7 +351,7 @@ class HealthBotKey(_serialization.Model): "value": {"key": "value", "type": "str"}, } - def __init__(self, *, key_name: Optional[str] = None, value: Optional[str] = None, **kwargs): + def __init__(self, *, key_name: Optional[str] = None, value: Optional[str] = None, **kwargs: Any) -> None: """ :keyword key_name: The name of the key. :paramtype key_name: str @@ -374,7 +374,7 @@ class HealthBotKeysResponse(_serialization.Model): "secrets": {"key": "secrets", "type": "[HealthBotKey]"}, } - def __init__(self, *, secrets: Optional[List["_models.HealthBotKey"]] = None, **kwargs): + def __init__(self, *, secrets: Optional[List["_models.HealthBotKey"]] = None, **kwargs: Any) -> None: """ :keyword secrets: Array of Azure Health Bot Secrets. :paramtype secrets: list[~azure.mgmt.healthbot.models.HealthBotKey] @@ -384,7 +384,9 @@ def __init__(self, *, secrets: Optional[List["_models.HealthBotKey"]] = None, ** class HealthBotProperties(_serialization.Model): - """The properties of a Azure Health Bot. The Health Bot Service is a cloud platform that empowers developers in Healthcare organizations to build and deploy their compliant, AI-powered virtual health assistants and health bots, that help them improve processes and reduce costs. + """The properties of a Azure Health Bot. The Health Bot Service is a cloud platform that empowers + developers in Healthcare organizations to build and deploy their compliant, AI-powered virtual + health assistants and health bots, that help them improve processes and reduce costs. Variables are only populated by the server, and will be ignored when sending a request. @@ -407,7 +409,7 @@ class HealthBotProperties(_serialization.Model): "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, } - def __init__(self, *, key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs): + def __init__(self, *, key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs: Any) -> None: """ :keyword key_vault_properties: KeyVault properties for the resource encryption. :paramtype key_vault_properties: ~azure.mgmt.healthbot.models.KeyVaultProperties @@ -449,8 +451,8 @@ def __init__( sku: Optional["_models.Sku"] = None, identity: Optional["_models.Identity"] = None, location: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword properties: Properties of Azure Health Bot. :paramtype properties: ~azure.mgmt.healthbot.models.HealthBotProperties @@ -510,8 +512,8 @@ def __init__( *, type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword type: The identity type. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove @@ -565,8 +567,8 @@ def __init__( key_vault_uri: str, key_version: Optional[str] = None, user_identity: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword key_name: The name of the key vault key. Required. :paramtype key_name: str @@ -616,8 +618,8 @@ def __init__( display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, properties: Optional[JSON] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Name of the operation. :paramtype name: str @@ -665,8 +667,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Resource provider of the operation. :paramtype provider: str @@ -689,8 +691,8 @@ class Sku(_serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar name: The name of the Azure Health Bot SKU. Required. Known values are: "F0", "S1", and - "C0". + :ivar name: The name of the Azure Health Bot SKU. Required. Known values are: "F0", "S1", "C0", + and "PES". :vartype name: str or ~azure.mgmt.healthbot.models.SkuName """ @@ -702,10 +704,10 @@ class Sku(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs: Any) -> None: """ :keyword name: The name of the Azure Health Bot SKU. Required. Known values are: "F0", "S1", - and "C0". + "C0", and "PES". :paramtype name: str or ~azure.mgmt.healthbot.models.SkuName """ super().__init__(**kwargs) @@ -749,8 +751,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.IdentityType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -797,7 +799,7 @@ class UserAssignedIdentity(_serialization.Model): "client_id": {"key": "clientId", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.principal_id = None @@ -815,7 +817,7 @@ class ValidationResult(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, status: Optional[str] = None, **kwargs): + def __init__(self, *, status: Optional[str] = None, **kwargs: Any) -> None: """ :keyword status: The status code of the response validation. :paramtype status: str diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/operations/__init__.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/operations/__init__.py index 6375fff9b1ba1..16455565e5867 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/operations/__init__.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/operations/__init__.py @@ -10,7 +10,7 @@ from ._operations import Operations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/operations/_bots_operations.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/operations/_bots_operations.py index 5985220c790e0..e0a7d8802f1ae 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/operations/_bots_operations.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/operations/_bots_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -32,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,8 +43,8 @@ def build_create_request(resource_group_name: str, bot_name: str, subscription_i _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) # type: Literal["2022-08-08"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +67,7 @@ def build_create_request(resource_group_name: str, bot_name: str, subscription_i ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -88,7 +84,7 @@ def build_get_request(resource_group_name: str, bot_name: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) # type: Literal["2022-08-08"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -111,7 +107,7 @@ def build_get_request(resource_group_name: str, bot_name: str, subscription_id: ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,8 +122,8 @@ def build_update_request(resource_group_name: str, bot_name: str, subscription_i _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) # type: Literal["2022-08-08"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -150,7 +146,7 @@ def build_update_request(resource_group_name: str, bot_name: str, subscription_i ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,7 +163,7 @@ def build_delete_request(resource_group_name: str, bot_name: str, subscription_i _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) # type: Literal["2022-08-08"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -190,7 +186,7 @@ def build_delete_request(resource_group_name: str, bot_name: str, subscription_i ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -207,7 +203,7 @@ def build_list_secrets_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) # type: Literal["2022-08-08"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -230,7 +226,7 @@ def build_list_secrets_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -247,7 +243,7 @@ def build_regenerate_api_jwt_secret_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) # type: Literal["2022-08-08"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -270,7 +266,7 @@ def build_regenerate_api_jwt_secret_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -285,7 +281,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) # type: Literal["2022-08-08"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -305,7 +301,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -320,7 +316,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) # type: Literal["2022-08-08"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -329,7 +325,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -373,16 +369,14 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthBot] + 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.HealthBot] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "HealthBot") @@ -400,10 +394,11 @@ def _create_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -420,11 +415,13 @@ def _create_initial( deserialized = self._deserialize("HealthBot", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" + } @overload def begin_create( @@ -508,7 +505,7 @@ def begin_create( :param bot_name: The name of the Bot resource. Required. :type bot_name: str :param parameters: The parameters to provide for the created Azure Health Bot. Is either a - model type or a IO type. Required. + HealthBot type or a IO type. Required. :type parameters: ~azure.mgmt.healthbot.models.HealthBot or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -528,16 +525,14 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthBot] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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.HealthBot] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_initial( # type: ignore + raw_result = self._create_initial( resource_group_name=resource_group_name, bot_name=bot_name, parameters=parameters, @@ -557,9 +552,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) # type: PollingMethod + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -571,9 +566,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" + } @distributed_trace def get(self, resource_group_name: str, bot_name: str, **kwargs: Any) -> _models.HealthBot: @@ -600,10 +597,8 @@ def get(self, resource_group_name: str, bot_name: str, **kwargs: Any) -> _models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthBot] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.HealthBot] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -615,10 +610,11 @@ def get(self, resource_group_name: str, bot_name: str, **kwargs: Any) -> _models params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -635,10 +631,84 @@ def get(self, resource_group_name: str, bot_name: str, **kwargs: Any) -> _models return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" + } + + def _update_initial( + self, + resource_group_name: str, + bot_name: str, + parameters: Union[_models.HealthBotUpdateParameters, IO], + **kwargs: Any + ) -> _models.HealthBot: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.HealthBot] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "HealthBotUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + bot_name=bot_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("HealthBot", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("HealthBot", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" + } @overload - def update( + def begin_update( self, resource_group_name: str, bot_name: str, @@ -646,7 +716,7 @@ def update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.HealthBot: + ) -> LROPoller[_models.HealthBot]: """Patch a HealthBot. :param resource_group_name: The name of the Bot resource group in the user subscription. @@ -660,13 +730,20 @@ def update( Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HealthBot or the result of cls(response) - :rtype: ~azure.mgmt.healthbot.models.HealthBot + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either HealthBot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.healthbot.models.HealthBot] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( + def begin_update( self, resource_group_name: str, bot_name: str, @@ -674,7 +751,7 @@ def update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.HealthBot: + ) -> LROPoller[_models.HealthBot]: """Patch a HealthBot. :param resource_group_name: The name of the Bot resource group in the user subscription. @@ -688,19 +765,26 @@ def update( Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HealthBot or the result of cls(response) - :rtype: ~azure.mgmt.healthbot.models.HealthBot + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either HealthBot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.healthbot.models.HealthBot] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update( + def begin_update( self, resource_group_name: str, bot_name: str, parameters: Union[_models.HealthBotUpdateParameters, IO], **kwargs: Any - ) -> _models.HealthBot: + ) -> LROPoller[_models.HealthBot]: """Patch a HealthBot. :param resource_group_name: The name of the Bot resource group in the user subscription. @@ -709,79 +793,70 @@ def update( :param bot_name: The name of the Bot resource. Required. :type bot_name: str :param parameters: The parameters to provide for the required Azure Health Bot. Is either a - model type or a IO type. Required. + HealthBotUpdateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.healthbot.models.HealthBotUpdateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HealthBot or the result of cls(response) - :rtype: ~azure.mgmt.healthbot.models.HealthBot + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either HealthBot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.healthbot.models.HealthBot] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthBot] - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "HealthBotUpdateParameters") - - request = build_update_request( - resource_group_name=resource_group_name, - bot_name=bot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("HealthBot", pipeline_response) + 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.HealthBot] = 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._update_initial( + resource_group_name=resource_group_name, + bot_name=bot_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - if response.status_code == 201: + def get_long_running_output(pipeline_response): deserialized = self._deserialize("HealthBot", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, bot_name: str, **kwargs: Any @@ -797,10 +872,8 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -812,10 +885,11 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -828,7 +902,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" + } @distributed_trace def begin_delete(self, resource_group_name: str, bot_name: str, **kwargs: Any) -> LROPoller[None]: @@ -854,13 +930,11 @@ def begin_delete(self, resource_group_name: str, bot_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -878,7 +952,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -890,9 +964,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" + } @distributed_trace def list_secrets(self, resource_group_name: str, bot_name: str, **kwargs: Any) -> _models.HealthBotKeysResponse: @@ -919,10 +995,8 @@ def list_secrets(self, resource_group_name: str, bot_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthBotKeysResponse] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.HealthBotKeysResponse] = kwargs.pop("cls", None) request = build_list_secrets_request( resource_group_name=resource_group_name, @@ -934,10 +1008,11 @@ def list_secrets(self, resource_group_name: str, bot_name: str, **kwargs: Any) - params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -954,7 +1029,9 @@ def list_secrets(self, resource_group_name: str, bot_name: str, **kwargs: Any) - return deserialized - list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/listSecrets"} # type: ignore + list_secrets.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/listSecrets" + } @distributed_trace def regenerate_api_jwt_secret(self, resource_group_name: str, bot_name: str, **kwargs: Any) -> _models.HealthBotKey: @@ -981,10 +1058,8 @@ def regenerate_api_jwt_secret(self, resource_group_name: str, bot_name: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.HealthBotKey] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.HealthBotKey] = kwargs.pop("cls", None) request = build_regenerate_api_jwt_secret_request( resource_group_name=resource_group_name, @@ -996,10 +1071,11 @@ def regenerate_api_jwt_secret(self, resource_group_name: str, bot_name: str, **k params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1016,7 +1092,9 @@ def regenerate_api_jwt_secret(self, resource_group_name: str, bot_name: str, **k return deserialized - regenerate_api_jwt_secret.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/regenerateApiJwtSecret"} # type: ignore + regenerate_api_jwt_secret.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/regenerateApiJwtSecret" + } @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.HealthBot"]: @@ -1033,10 +1111,8 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.BotResponseList] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BotResponseList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1058,7 +1134,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -1074,7 +1150,7 @@ def prepare_request(next_link=None): "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) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1082,14 +1158,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("BotResponseList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1102,7 +1179,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots" + } @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.HealthBot"]: @@ -1116,10 +1195,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.HealthBot"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.BotResponseList] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BotResponseList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1140,7 +1217,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -1156,7 +1233,7 @@ def prepare_request(next_link=None): "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) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1164,14 +1241,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("BotResponseList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1184,4 +1262,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HealthBot/healthBots"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HealthBot/healthBots"} diff --git a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/operations/_operations.py b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/operations/_operations.py index a64d1bc149c10..8ce0e66f10c3e 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/operations/_operations.py +++ b/sdk/healthbot/azure-mgmt-healthbot/azure/mgmt/healthbot/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) # type: Literal["2022-08-08"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,10 +86,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.OperationDetail"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-08-08"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableOperations] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AvailableOperations] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -114,7 +107,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -130,7 +123,7 @@ def prepare_request(next_link=None): "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) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -138,14 +131,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AvailableOperations", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -158,4 +152,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.HealthBot/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.HealthBot/operations"} diff --git a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/get_operations.py b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/get_operations.py index 3a0e489032009..7184a900b285e 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/get_operations.py +++ b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/get_operations.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2022-08-08/examples/GetOperations.json +# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2023-05-01/examples/GetOperations.json if __name__ == "__main__": main() diff --git a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/list_bots_by_resource_group.py b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/list_bots_by_resource_group.py index e26b236363eb8..f2980cbc958be 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/list_bots_by_resource_group.py +++ b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/list_bots_by_resource_group.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2022-08-08/examples/ListBotsByResourceGroup.json +# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2023-05-01/examples/ListBotsByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/list_bots_by_subscription.py b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/list_bots_by_subscription.py index 73f13fe5b2c44..d6efa1867e3d5 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/list_bots_by_subscription.py +++ b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/list_bots_by_subscription.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2022-08-08/examples/ListBotsBySubscription.json +# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2023-05-01/examples/ListBotsBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_list_secrets.py b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/list_secrets.py similarity index 93% rename from sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_list_secrets.py rename to sdk/healthbot/azure-mgmt-healthbot/generated_samples/list_secrets.py index 3e5573962913d..3a42c3397385a 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_list_secrets.py +++ b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/list_secrets.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-healthbot # USAGE - python bot_list_secrets.py + python list_secrets.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, @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2022-08-08/examples/ListSecrets.json +# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2023-05-01/examples/ListSecrets.json if __name__ == "__main__": main() diff --git a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_regenerate_api_jwt_secret.py b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/regenerate_api_jwt_secret.py similarity index 93% rename from sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_regenerate_api_jwt_secret.py rename to sdk/healthbot/azure-mgmt-healthbot/generated_samples/regenerate_api_jwt_secret.py index 179cd3ee357a5..88ae7d7c22df5 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_regenerate_api_jwt_secret.py +++ b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/regenerate_api_jwt_secret.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-healthbot # USAGE - python bot_regenerate_api_jwt_secret.py + python regenerate_api_jwt_secret.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, @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2022-08-08/examples/RegenerateApiJwtSecret.json +# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2023-05-01/examples/RegenerateApiJwtSecret.json if __name__ == "__main__": main() diff --git a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_create.py b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/resource_creation_put.py similarity index 95% rename from sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_create.py rename to sdk/healthbot/azure-mgmt-healthbot/generated_samples/resource_creation_put.py index 2157c01062a55..d1b06da72634a 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_create.py +++ b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/resource_creation_put.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-healthbot # USAGE - python bot_create.py + python resource_creation_put.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, @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2022-08-08/examples/ResourceCreationPut.json +# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2023-05-01/examples/ResourceCreationPut.json if __name__ == "__main__": main() diff --git a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_delete.py b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/resource_deletion_delete.py similarity index 90% rename from sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_delete.py rename to sdk/healthbot/azure-mgmt-healthbot/generated_samples/resource_deletion_delete.py index 31671198863f2..c5baf099bcd38 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_delete.py +++ b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/resource_deletion_delete.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-healthbot # USAGE - python bot_delete.py + python resource_deletion_delete.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, @@ -29,13 +29,12 @@ def main(): subscription_id="subid", ) - response = client.bots.begin_delete( + client.bots.begin_delete( resource_group_name="healthbotClient", bot_name="samplebotname", ).result() - print(response) -# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2022-08-08/examples/ResourceDeletionDelete.json +# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2023-05-01/examples/ResourceDeletionDelete.json if __name__ == "__main__": main() diff --git a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/resource_info_get.py b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/resource_info_get.py index 2377803554458..be1ab0365013a 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/resource_info_get.py +++ b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/resource_info_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2022-08-08/examples/ResourceInfoGet.json +# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2023-05-01/examples/ResourceInfoGet.json if __name__ == "__main__": main() diff --git a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_update.py b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/resource_update_patch.py similarity index 90% rename from sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_update.py rename to sdk/healthbot/azure-mgmt-healthbot/generated_samples/resource_update_patch.py index c08384d3a7e92..eb747cc88ac24 100644 --- a/sdk/healthbot/azure-mgmt-healthbot/generated_samples/bot_update.py +++ b/sdk/healthbot/azure-mgmt-healthbot/generated_samples/resource_update_patch.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-healthbot # USAGE - python bot_update.py + python resource_update_patch.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, @@ -29,14 +29,14 @@ def main(): subscription_id="subid", ) - response = client.bots.update( + response = client.bots.begin_update( resource_group_name="healthbotClient", bot_name="samplebotname", parameters={"sku": {"name": "F0"}}, - ) + ).result() print(response) -# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2022-08-08/examples/ResourceUpdatePatch.json +# x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2023-05-01/examples/ResourceUpdatePatch.json if __name__ == "__main__": main()