From 7db458653ced84d1875309b9bd357b1345fd5063 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 25 Oct 2023 11:25:01 +0000 Subject: [PATCH] CodeGen from PR 26369 in Azure/azure-rest-api-specs Merge 972c19d750923940753991a7045685e517d0ed57 into a032c2413b49d297196a0c64393e862433fccbb1 --- .../azure-mgmt-servicefabric/_meta.json | 10 +- .../azure/mgmt/servicefabric/__init__.py | 2 +- .../mgmt/servicefabric/_configuration.py | 13 +- .../mgmt/servicefabric/_serialization.py | 206 ++++++---- .../_service_fabric_management_client.py | 15 +- .../azure/mgmt/servicefabric/_vendor.py | 11 - .../azure/mgmt/servicefabric/_version.py | 2 +- .../azure/mgmt/servicefabric/aio/__init__.py | 2 +- .../mgmt/servicefabric/aio/_configuration.py | 8 +- .../aio/_service_fabric_management_client.py | 8 +- .../servicefabric/aio/operations/__init__.py | 2 +- .../_application_type_versions_operations.py | 218 +++++----- .../_application_types_operations.py | 194 +++++---- .../operations/_applications_operations.py | 261 +++++++----- .../_cluster_versions_operations.py | 73 ++-- .../aio/operations/_clusters_operations.py | 355 +++++++++------- .../aio/operations/_operations.py | 24 +- .../aio/operations/_services_operations.py | 263 ++++++------ .../mgmt/servicefabric/models/__init__.py | 2 +- .../mgmt/servicefabric/models/_models_py3.py | 316 +++++++------- ..._service_fabric_management_client_enums.py | 188 ++++----- .../mgmt/servicefabric/operations/__init__.py | 2 +- .../_application_type_versions_operations.py | 233 ++++++----- .../_application_types_operations.py | 210 ++++++---- .../operations/_applications_operations.py | 283 +++++++------ .../_cluster_versions_operations.py | 91 ++--- .../operations/_clusters_operations.py | 386 ++++++++++-------- .../servicefabric/operations/_operations.py | 26 +- .../operations/_services_operations.py | 283 +++++++------ ...> application_delete_operation_example.py} | 5 +- ...y => application_get_operation_example.py} | 2 +- ... => application_list_operation_example.py} | 5 +- ...=> application_patch_operation_example.py} | 2 +- ... application_put_operation_example_max.py} | 2 +- ... application_put_operation_example_min.py} | 2 +- ...ication_put_operation_recreate_example.py} | 2 +- ...ion_type_name_delete_operation_example.py} | 5 +- ...cation_type_name_get_operation_example.py} | 2 +- ...ation_type_name_list_operation_example.py} | 5 +- ...cation_type_name_put_operation_example.py} | 2 +- ..._type_version_delete_operation_example.py} | 5 +- ...ion_type_version_get_operation_example.py} | 2 +- ...on_type_version_list_operation_example.py} | 5 +- ...ion_type_version_put_operation_example.py} | 2 +- ...py => cluster_delete_operation_example.py} | 5 +- ...er.py => cluster_get_operation_example.py} | 2 +- ...st_by_resource_group_operation_example.py} | 5 +- ...s.py => cluster_list_operation_example.py} | 5 +- ....py => cluster_patch_operation_example.py} | 2 +- ...y => cluster_put_operation_example_max.py} | 2 +- ...y => cluster_put_operation_example_min.py} | 2 +- ...er_versions_get_by_environment_example.py} | 2 +- ...ion.py => cluster_versions_get_example.py} | 2 +- ...> cluster_versions_list_by_environment.py} | 2 +- ...ns.py => cluster_versions_list_example.py} | 2 +- ...st_upgradable_versions_min_max_example.py} | 2 +- ... list_upgradable_versions_path_example.py} | 2 +- ...py => service_delete_operation_example.py} | 5 +- ...ce.py => service_get_operation_example.py} | 2 +- ...s.py => service_list_operation_example.py} | 5 +- ....py => service_patch_operation_example.py} | 2 +- ...y => service_put_operation_example_max.py} | 2 +- ...y => service_put_operation_example_min.py} | 2 +- 63 files changed, 2091 insertions(+), 1697 deletions(-) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{delete_an_application.py => application_delete_operation_example.py} (93%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{get_an_application.py => application_get_operation_example.py} (97%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{get_a_list_of_application_resources.py => application_list_operation_example.py} (94%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{patch_an_application.py => application_patch_operation_example.py} (97%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{put_an_application_with_maximum_parameters.py => application_put_operation_example_max.py} (98%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{put_an_application_with_minimum_parameters.py => application_put_operation_example_min.py} (96%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{put_an_application_with_recreate_option.py => application_put_operation_recreate_example.py} (97%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{delete_an_application_type.py => application_type_name_delete_operation_example.py} (93%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{get_an_application_type.py => application_type_name_get_operation_example.py} (96%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{get_a_list_of_application_type_name_resources.py => application_type_name_list_operation_example.py} (93%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{put_an_application_type.py => application_type_name_put_operation_example.py} (96%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{delete_an_application_type_version.py => application_type_version_delete_operation_example.py} (92%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{get_an_application_type_version.py => application_type_version_get_operation_example.py} (96%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{get_a_list_of_application_type_version_resources.py => application_type_version_list_operation_example.py} (93%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{put_an_application_type_version.py => application_type_version_put_operation_example.py} (96%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{delete_a_cluster.py => cluster_delete_operation_example.py} (94%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{get_a_cluster.py => cluster_get_operation_example.py} (97%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{list_cluster_by_resource_group.py => cluster_list_by_resource_group_operation_example.py} (93%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{list_clusters.py => cluster_list_operation_example.py} (94%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{patch_a_cluster.py => cluster_patch_operation_example.py} (98%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{put_a_cluster_with_maximum_parameters.py => cluster_put_operation_example_max.py} (99%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{put_a_cluster_with_minimum_parameters.py => cluster_put_operation_example_min.py} (98%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{get_cluster_version_by_environment.py => cluster_versions_get_by_environment_example.py} (96%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{get_cluster_version.py => cluster_versions_get_example.py} (97%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{list_cluster_versions_by_environment.py => cluster_versions_list_by_environment.py} (96%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{list_cluster_versions.py => cluster_versions_list_example.py} (97%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{get_minimum_and_maximum_code_versions.py => list_upgradable_versions_min_max_example.py} (96%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{get_upgrade_path.py => list_upgradable_versions_path_example.py} (96%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{delete_a_service.py => service_delete_operation_example.py} (94%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{get_a_service.py => service_get_operation_example.py} (97%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{get_a_list_of_service_resources.py => service_list_operation_example.py} (94%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{patch_a_service.py => service_patch_operation_example.py} (97%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{put_a_service_with_maximum_parameters.py => service_put_operation_example_max.py} (97%) rename sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/{put_a_service_with_minimum_parameters.py => service_put_operation_example_min.py} (97%) diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/_meta.json b/sdk/servicefabric/azure-mgmt-servicefabric/_meta.json index 1045106544a3..46c83e6c5759 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/_meta.json +++ b/sdk/servicefabric/azure-mgmt-servicefabric/_meta.json @@ -1,11 +1,11 @@ { - "commit": "51db80e40c32f4bf4c57169476d81d36fb8c81d8", + "commit": "a11d7da269f1dd579ef2dfcda4029465ae7ee1a6", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.9.7", "use": [ - "@autorest/python@6.2.1", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.7.1", + "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/servicefabric/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/servicefabric/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", "readme": "specification/servicefabric/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/__init__.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/__init__.py index b4beea682843..a1e1b6c82e5b 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/__init__.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/__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/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_configuration.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_configuration.py index f9505f58e07e..4a367fa79829 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_configuration.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_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 @@ -42,7 +36,7 @@ class ServiceFabricManagementClientConfiguration(Configuration): # pylint: disa def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ServiceFabricManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-06-01") # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", "2021-06-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-servicefabric/{}".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/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_serialization.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_serialization.py index 7c1dedb5133d..4bae2292227b 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_serialization.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_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,26 +645,26 @@ 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 + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) @@ -659,8 +683,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 +699,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: @@ -718,6 +742,8 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None @@ -726,10 +752,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -780,6 +804,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 +869,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 @@ -866,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -878,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -925,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -1001,10 +1036,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 +1199,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 +1281,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1269,7 +1305,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): @@ -1335,7 +1371,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 +1391,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 +1452,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 +1480,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 +1510,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 +1525,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 +1535,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 +1579,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 +1601,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 +1783,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 +1834,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 +1846,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 +1862,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 +1877,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 +1907,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 +1922,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 +1937,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 +1960,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 +1996,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/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_service_fabric_management_client.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_service_fabric_management_client.py index 7b2941cf9f5d..02462744f19e 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_service_fabric_management_client.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_service_fabric_management_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 ServiceFabricManagementClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( @@ -71,9 +71,9 @@ def __init__( self._config = ServiceFabricManagementClientConfiguration( 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 @@ -113,15 +113,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: () -> ServiceFabricManagementClient + def __enter__(self) -> "ServiceFabricManagementClient": 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/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_vendor.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_vendor.py index 9aad73fc743e..0dafe0e287ff 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_vendor.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_vendor.py @@ -14,14 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - formatted_components = template.split("/") - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_version.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_version.py index b82e03a368ff..e5754a47ce68 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_version.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0b1" +VERSION = "1.0.0b1" diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/__init__.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/__init__.py index 9d60dc161aef..82043be1c40a 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/__init__.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/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/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/_configuration.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/_configuration.py index c92d2ed703e6..5d3feba4ba0c 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/_configuration.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/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 @@ -42,7 +36,7 @@ class ServiceFabricManagementClientConfiguration(Configuration): # pylint: disa def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ServiceFabricManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-06-01") # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", "2021-06-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/_service_fabric_management_client.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/_service_fabric_management_client.py index 2a5d718c5ab9..6b45d50ad72e 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/_service_fabric_management_client.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/_service_fabric_management_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 ServiceFabricManagementClientConfiguration from .operations import ( @@ -71,9 +71,9 @@ def __init__( self._config = ServiceFabricManagementClientConfiguration( 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 @@ -120,5 +120,5 @@ async def __aenter__(self) -> "ServiceFabricManagementClient": 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/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/__init__.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/__init__.py index 69103382d011..aa1919dd5f64 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/__init__.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/__init__.py @@ -15,7 +15,7 @@ from ._services_operations import ServicesOperations 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/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_application_type_versions_operations.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_application_type_versions_operations.py index 07815c452976..d010284a9e92 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_application_type_versions_operations.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_application_type_versions_operations.py @@ -6,9 +6,11 @@ # 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, IO, Optional, TypeVar, Union, cast, overload +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -21,6 +23,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -35,10 +38,6 @@ 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]] @@ -95,10 +94,8 @@ async def get( _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationTypeVersionResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplicationTypeVersionResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -112,10 +109,11 @@ async def get( 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 @@ -132,7 +130,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}" + } async def _create_or_update_initial( self, @@ -154,16 +154,14 @@ async def _create_or_update_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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationTypeVersionResource] + 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.ApplicationTypeVersionResource] = 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, "ApplicationTypeVersionResource") @@ -183,10 +181,11 @@ async def _create_or_update_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 @@ -203,7 +202,9 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}" + } @overload async def begin_create_or_update( @@ -315,8 +316,8 @@ async def begin_create_or_update( :type application_type_name: str :param version: The application type version. Required. :type version: str - :param parameters: The application type version resource. Is either a model type or a IO type. - Required. + :param parameters: The application type version resource. Is either a + ApplicationTypeVersionResource type or a IO type. Required. :type parameters: ~azure.mgmt.servicefabric.models.ApplicationTypeVersionResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -338,16 +339,14 @@ async def begin_create_or_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationTypeVersionResource] - 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.ApplicationTypeVersionResource] = 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_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, application_type_name=application_type_name, @@ -369,7 +368,7 @@ def get_long_running_output(pipeline_response): return deserialized 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: @@ -381,9 +380,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_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, application_type_name: str, version: str, **kwargs: Any @@ -399,10 +400,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["2021-06-01"] - 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, @@ -416,10 +415,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 @@ -432,7 +432,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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}" + } @distributed_trace_async async def begin_delete( @@ -465,13 +467,11 @@ async def begin_delete( _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["2021-06-01"] - 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, @@ -491,7 +491,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: @@ -503,14 +503,16 @@ 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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}" + } - @distributed_trace_async - async def list( + @distributed_trace + def list( self, resource_group_name: str, cluster_name: str, application_type_name: str, **kwargs: Any - ) -> _models.ApplicationTypeVersionResourceList: + ) -> AsyncIterable["_models.ApplicationTypeVersionResource"]: """Gets the list of application type version resources created in the specified Service Fabric application type name resource. @@ -524,10 +526,18 @@ async def list( :param application_type_name: The name of the application type name resource. Required. :type application_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationTypeVersionResourceList or the result of cls(response) - :rtype: ~azure.mgmt.servicefabric.models.ApplicationTypeVersionResourceList + :return: An iterator like instance of either ApplicationTypeVersionResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicefabric.models.ApplicationTypeVersionResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplicationTypeVersionResourceList] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -536,43 +546,65 @@ async def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationTypeVersionResourceList] - - request = build_list_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - application_type_name=application_type_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.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 - ) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + application_type_name=application_type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationTypeVersionResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("ApplicationTypeVersionResourceList", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions" + } diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_application_types_operations.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_application_types_operations.py index a11ceec2680f..496b973b8c23 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_application_types_operations.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_application_types_operations.py @@ -6,9 +6,11 @@ # 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, IO, Optional, TypeVar, Union, cast, overload +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -21,6 +23,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -35,10 +38,6 @@ 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]] @@ -93,10 +92,8 @@ async def get( _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationTypeResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplicationTypeResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -109,10 +106,11 @@ async def get( 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 @@ -129,7 +127,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}" + } @overload async def create_or_update( @@ -214,8 +214,8 @@ async def create_or_update( :type cluster_name: str :param application_type_name: The name of the application type name resource. Required. :type application_type_name: str - :param parameters: The application type name resource. Is either a model type or a IO type. - Required. + :param parameters: The application type name resource. Is either a ApplicationTypeResource type + or a IO type. Required. :type parameters: ~azure.mgmt.servicefabric.models.ApplicationTypeResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -236,16 +236,14 @@ async def create_or_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationTypeResource] + 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.ApplicationTypeResource] = 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, "ApplicationTypeResource") @@ -264,10 +262,11 @@ async def create_or_update( 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 @@ -284,7 +283,9 @@ async def create_or_update( return deserialized - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, application_type_name: str, **kwargs: Any @@ -300,10 +301,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["2021-06-01"] - 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, @@ -316,10 +315,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 @@ -332,7 +332,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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}" + } @distributed_trace_async async def begin_delete( @@ -363,13 +365,11 @@ async def begin_delete( _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["2021-06-01"] - 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, @@ -388,7 +388,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: @@ -400,14 +400,16 @@ 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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}" + } - @distributed_trace_async - async def list( + @distributed_trace + def list( self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> _models.ApplicationTypeResourceList: + ) -> AsyncIterable["_models.ApplicationTypeResource"]: """Gets the list of application type name resources created in the specified Service Fabric cluster resource. @@ -419,10 +421,18 @@ async def list( :param cluster_name: The name of the cluster resource. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationTypeResourceList or the result of cls(response) - :rtype: ~azure.mgmt.servicefabric.models.ApplicationTypeResourceList + :return: An iterator like instance of either ApplicationTypeResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicefabric.models.ApplicationTypeResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplicationTypeResourceList] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -431,42 +441,64 @@ async def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationTypeResourceList] - - request = build_list_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.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 - ) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationTypeResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("ApplicationTypeResourceList", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes" + } diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_applications_operations.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_applications_operations.py index 17a29a414e21..36190bb0b8cb 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_applications_operations.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_applications_operations.py @@ -6,9 +6,11 @@ # 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, IO, Optional, TypeVar, Union, cast, overload +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -21,6 +23,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -36,10 +39,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]] @@ -94,10 +93,8 @@ async def get( _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplicationResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -110,10 +107,11 @@ async def get( 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,7 +128,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}" + } async def _create_or_update_initial( self, @@ -151,16 +151,14 @@ async def _create_or_update_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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationResource] + 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.ApplicationResource] = 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, "ApplicationResource") @@ -179,10 +177,11 @@ async def _create_or_update_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 @@ -199,7 +198,9 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}" + } @overload async def begin_create_or_update( @@ -302,7 +303,8 @@ async def begin_create_or_update( :type cluster_name: str :param application_name: The name of the application resource. Required. :type application_name: str - :param parameters: The application resource. Is either a model type or a IO type. Required. + :param parameters: The application resource. Is either a ApplicationResource type or a IO type. + Required. :type parameters: ~azure.mgmt.servicefabric.models.ApplicationResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -324,16 +326,14 @@ async def begin_create_or_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationResource] - 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.ApplicationResource] = 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_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, application_name=application_name, @@ -354,7 +354,7 @@ def get_long_running_output(pipeline_response): return deserialized 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: @@ -366,9 +366,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_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}" + } async def _update_initial( self, @@ -389,16 +391,14 @@ async def _update_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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationResource] + 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.ApplicationResource] = 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, "ApplicationResourceUpdate") @@ -417,10 +417,11 @@ async def _update_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 @@ -437,7 +438,9 @@ async def _update_initial( return deserialized - _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}" + } @overload async def begin_update( @@ -540,8 +543,8 @@ async def begin_update( :type cluster_name: str :param application_name: The name of the application resource. Required. :type application_name: str - :param parameters: The application resource for patch operations. Is either a model type or a - IO type. Required. + :param parameters: The application resource for patch operations. Is either a + ApplicationResourceUpdate type or a IO type. Required. :type parameters: ~azure.mgmt.servicefabric.models.ApplicationResourceUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -563,16 +566,14 @@ async def begin_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationResource] - 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.ApplicationResource] = 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._update_initial( # type: ignore + raw_result = await self._update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, application_name=application_name, @@ -593,7 +594,7 @@ def get_long_running_output(pipeline_response): return deserialized 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: @@ -605,9 +606,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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, application_name: str, **kwargs: Any @@ -623,10 +626,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["2021-06-01"] - 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, @@ -639,10 +640,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 @@ -655,7 +657,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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}" + } @distributed_trace_async async def begin_delete( @@ -686,13 +690,11 @@ async def begin_delete( _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["2021-06-01"] - 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, @@ -711,7 +713,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: @@ -723,12 +725,16 @@ 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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}" + } - @distributed_trace_async - async def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.ApplicationResourceList: + @distributed_trace + def list( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApplicationResource"]: """Gets the list of application resources created in the specified Service Fabric cluster resource. @@ -740,10 +746,17 @@ async def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) :param cluster_name: The name of the cluster resource. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationResourceList or the result of cls(response) - :rtype: ~azure.mgmt.servicefabric.models.ApplicationResourceList + :return: An iterator like instance of either ApplicationResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicefabric.models.ApplicationResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplicationResourceList] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -752,42 +765,64 @@ async def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) } error_map.update(kwargs.pop("error_map", {}) or {}) - _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationResourceList] - - request = build_list_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.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 - ) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("ApplicationResourceList", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications" + } diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_cluster_versions_operations.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_cluster_versions_operations.py index 16ec5331b2bc..1350cdbd0034 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_cluster_versions_operations.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_cluster_versions_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -33,10 +32,6 @@ 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]] @@ -88,10 +83,8 @@ async def get(self, location: str, cluster_version: str, **kwargs: Any) -> _mode _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterCodeVersionsListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterCodeVersionsListResult] = kwargs.pop("cls", None) request = build_get_request( location=location, @@ -103,10 +96,11 @@ async def get(self, location: str, cluster_version: str, **kwargs: Any) -> _mode 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 @@ -123,7 +117,9 @@ async def get(self, location: str, cluster_version: str, **kwargs: Any) -> _mode return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/clusterVersions/{clusterVersion}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/clusterVersions/{clusterVersion}" + } @distributed_trace_async async def get_by_environment( @@ -162,10 +158,8 @@ async def get_by_environment( _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterCodeVersionsListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterCodeVersionsListResult] = kwargs.pop("cls", None) request = build_get_by_environment_request( location=location, @@ -178,10 +172,11 @@ async def get_by_environment( 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 @@ -198,7 +193,9 @@ async def get_by_environment( return deserialized - get_by_environment.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/environments/{environment}/clusterVersions/{clusterVersion}"} # type: ignore + get_by_environment.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/environments/{environment}/clusterVersions/{clusterVersion}" + } @distributed_trace_async async def list(self, location: str, **kwargs: Any) -> _models.ClusterCodeVersionsListResult: @@ -225,10 +222,8 @@ async def list(self, location: str, **kwargs: Any) -> _models.ClusterCodeVersion _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterCodeVersionsListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterCodeVersionsListResult] = kwargs.pop("cls", None) request = build_list_request( location=location, @@ -239,10 +234,11 @@ async def list(self, location: str, **kwargs: Any) -> _models.ClusterCodeVersion 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 @@ -259,7 +255,9 @@ async def list(self, location: str, **kwargs: Any) -> _models.ClusterCodeVersion return deserialized - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/clusterVersions"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/clusterVersions" + } @distributed_trace_async async def list_by_environment( @@ -291,10 +289,8 @@ async def list_by_environment( _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterCodeVersionsListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterCodeVersionsListResult] = kwargs.pop("cls", None) request = build_list_by_environment_request( location=location, @@ -306,10 +302,11 @@ async def list_by_environment( 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 @@ -326,4 +323,6 @@ async def list_by_environment( return deserialized - list_by_environment.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/environments/{environment}/clusterVersions"} # type: ignore + list_by_environment.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/environments/{environment}/clusterVersions" + } diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_clusters_operations.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_clusters_operations.py index 88c399eb4e1a..f889b2f9ab8c 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_clusters_operations.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_clusters_operations.py @@ -6,9 +6,11 @@ # 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, IO, Optional, TypeVar, Union, cast, overload +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -21,6 +23,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -38,10 +41,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]] @@ -92,10 +91,8 @@ async def get(self, resource_group_name: str, cluster_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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -107,10 +104,11 @@ async def get(self, resource_group_name: str, cluster_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 @@ -127,7 +125,9 @@ async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}" + } async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, parameters: Union[_models.Cluster, IO], **kwargs: Any @@ -143,16 +143,14 @@ async def _create_or_update_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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + 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.Cluster] = 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, "Cluster") @@ -170,10 +168,11 @@ async def _create_or_update_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 @@ -190,11 +189,13 @@ async def _create_or_update_initial( deserialized = self._deserialize("Cluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}" + } @overload async def begin_create_or_update( @@ -282,7 +283,7 @@ async def begin_create_or_update( :type resource_group_name: str :param cluster_name: The name of the cluster resource. Required. :type cluster_name: str - :param parameters: The cluster resource. Is either a model type or a IO type. Required. + :param parameters: The cluster resource. Is either a Cluster type or a IO type. Required. :type parameters: ~azure.mgmt.servicefabric.models.Cluster or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -303,16 +304,14 @@ async def begin_create_or_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] - 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.Cluster] = 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_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, @@ -332,7 +331,7 @@ def get_long_running_output(pipeline_response): return deserialized 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: @@ -344,9 +343,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_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}" + } async def _update_initial( self, @@ -366,16 +367,14 @@ async def _update_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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + 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.Cluster] = 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, "ClusterUpdateParameters") @@ -393,10 +392,11 @@ async def _update_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 @@ -413,11 +413,13 @@ async def _update_initial( deserialized = self._deserialize("Cluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}" + } @overload async def begin_update( @@ -512,7 +514,8 @@ async def begin_update( :param cluster_name: The name of the cluster resource. Required. :type cluster_name: str :param parameters: The parameters which contains the property value and property name which - used to update the cluster configuration. Is either a model type or a IO type. Required. + used to update the cluster configuration. Is either a ClusterUpdateParameters type or a IO + type. Required. :type parameters: ~azure.mgmt.servicefabric.models.ClusterUpdateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -533,16 +536,14 @@ async def begin_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] - 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.Cluster] = 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._update_initial( # type: ignore + raw_result = await self._update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, @@ -562,7 +563,7 @@ def get_long_running_output(pipeline_response): return deserialized 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: @@ -574,9 +575,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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -606,10 +609,8 @@ async def delete( # 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["2021-06-01"] - 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, @@ -621,10 +622,11 @@ async def delete( # 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 @@ -637,10 +639,12 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}" + } - @distributed_trace_async - async def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> _models.ClusterListResult: + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: """Gets the list of Service Fabric cluster resources created in the specified resource group. Gets all Service Fabric cluster resources created or in the process of being created in the @@ -649,10 +653,16 @@ async def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterListResult or the result of cls(response) - :rtype: ~azure.mgmt.servicefabric.models.ClusterListResult + :return: An iterator like instance of either Cluster or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicefabric.models.Cluster] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -661,57 +671,85 @@ async def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterListResult] + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) + async def get_next(next_link=None): + request = prepare_request(next_link) - response = pipeline_response.http_response + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ClusterListResult", pipeline_response) + return pipeline_response - if cls: - return cls(pipeline_response, deserialized, {}) + return AsyncItemPaged(get_next, extract_data) - return deserialized - - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters" + } - @distributed_trace_async - async def list(self, **kwargs: Any) -> _models.ClusterListResult: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: """Gets the list of Service Fabric cluster resources created in the specified subscription. Gets all Service Fabric cluster resources created or in the process of being created in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterListResult or the result of cls(response) - :rtype: ~azure.mgmt.servicefabric.models.ClusterListResult + :return: An iterator like instance of either Cluster or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicefabric.models.Cluster] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -720,43 +758,63 @@ async def list(self, **kwargs: Any) -> _models.ClusterListResult: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterListResult] - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 - ) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("ClusterListResult", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/clusters"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/clusters"} @overload async def list_upgradable_versions( @@ -844,7 +902,7 @@ async def list_upgradable_versions( :param cluster_name: The name of the cluster resource. Required. :type cluster_name: str :param versions_description: The upgrade path description with target version. Is either a - model type or a IO type. Default value is None. + UpgradableVersionsDescription type or a IO type. Default value is None. :type versions_description: ~azure.mgmt.servicefabric.models.UpgradableVersionsDescription or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -866,16 +924,14 @@ async def list_upgradable_versions( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.UpgradableVersionPathResult] + 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.UpgradableVersionPathResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(versions_description, (IO, bytes)): + if isinstance(versions_description, (IOBase, bytes)): _content = versions_description else: if versions_description is not None: @@ -896,10 +952,11 @@ async def list_upgradable_versions( 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 @@ -916,4 +973,6 @@ async def list_upgradable_versions( return deserialized - list_upgradable_versions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/listUpgradableVersions"} # type: ignore + list_upgradable_versions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/listUpgradableVersions" + } diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_operations.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_operations.py index ee2de086d6d1..0205e7638ae9 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_operations.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/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]] @@ -72,10 +67,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationResult"]: _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -95,7 +88,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 @@ -111,7 +104,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 @@ -119,14 +112,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", 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 @@ -139,4 +133,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.ServiceFabric/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceFabric/operations"} diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_services_operations.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_services_operations.py index a6e67358ba95..f8dd08b3ec58 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_services_operations.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/aio/operations/_services_operations.py @@ -6,9 +6,11 @@ # 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, IO, Optional, TypeVar, Union, cast, overload +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -21,6 +23,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -36,10 +39,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]] @@ -97,10 +96,8 @@ async def get( _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServiceResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -114,10 +111,11 @@ async def get( 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 @@ -134,7 +132,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}" + } async def _create_or_update_initial( self, @@ -156,16 +156,14 @@ async def _create_or_update_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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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.ServiceResource] = 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, "ServiceResource") @@ -185,10 +183,11 @@ async def _create_or_update_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 @@ -205,7 +204,9 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}" + } @overload async def begin_create_or_update( @@ -318,7 +319,8 @@ async def begin_create_or_update( :param service_name: The name of the service resource in the format of {applicationName}~{serviceName}. Required. :type service_name: str - :param parameters: The service resource. Is either a model type or a IO type. Required. + :param parameters: The service resource. Is either a ServiceResource type or a IO type. + Required. :type parameters: ~azure.mgmt.servicefabric.models.ServiceResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -339,16 +341,14 @@ async def begin_create_or_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - 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.ServiceResource] = 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_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, application_name=application_name, @@ -370,7 +370,7 @@ def get_long_running_output(pipeline_response): return deserialized 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: @@ -382,9 +382,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_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}" + } async def _update_initial( self, @@ -406,16 +408,14 @@ async def _update_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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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.ServiceResource] = 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, "ServiceResourceUpdate") @@ -435,10 +435,11 @@ async def _update_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 @@ -455,7 +456,9 @@ async def _update_initial( return deserialized - _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}" + } @overload async def begin_update( @@ -568,8 +571,8 @@ async def begin_update( :param service_name: The name of the service resource in the format of {applicationName}~{serviceName}. Required. :type service_name: str - :param parameters: The service resource for patch operations. Is either a model type or a IO - type. Required. + :param parameters: The service resource for patch operations. Is either a ServiceResourceUpdate + type or a IO type. Required. :type parameters: ~azure.mgmt.servicefabric.models.ServiceResourceUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -590,16 +593,14 @@ async def begin_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - 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.ServiceResource] = 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._update_initial( # type: ignore + raw_result = await self._update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, application_name=application_name, @@ -621,7 +622,7 @@ def get_long_running_output(pipeline_response): return deserialized 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: @@ -633,9 +634,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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, application_name: str, service_name: str, **kwargs: Any @@ -651,10 +654,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["2021-06-01"] - 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, @@ -668,10 +669,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 @@ -684,7 +686,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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}" + } @distributed_trace_async async def begin_delete( @@ -718,13 +722,11 @@ async def begin_delete( _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["2021-06-01"] - 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, @@ -744,7 +746,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: @@ -756,14 +758,16 @@ 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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}" + } - @distributed_trace_async - async def list( + @distributed_trace + def list( self, resource_group_name: str, cluster_name: str, application_name: str, **kwargs: Any - ) -> _models.ServiceResourceList: + ) -> AsyncIterable["_models.ServiceResource"]: """Gets the list of service resources created in the specified Service Fabric application resource. @@ -777,10 +781,17 @@ async def list( :param application_name: The name of the application resource. Required. :type application_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResourceList or the result of cls(response) - :rtype: ~azure.mgmt.servicefabric.models.ServiceResourceList + :return: An iterator like instance of either ServiceResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicefabric.models.ServiceResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServiceResourceList] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -789,43 +800,65 @@ async def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - - request = build_list_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.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 - ) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("ServiceResourceList", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services" + } diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/models/__init__.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/models/__init__.py index 70625ed68343..d3cf26904da5 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/models/__init__.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/models/__init__.py @@ -104,7 +104,7 @@ from ._service_fabric_management_client_enums import UpgradeMode from ._service_fabric_management_client_enums import VmssZonalUpgradeMode 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/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/models/_models_py3.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/models/_models_py3.py index 7f9f1ad9efe3..7b0724b3f88b 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/models/_models_py3.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/models/_models_py3.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from .. import _serialization @@ -18,7 +18,8 @@ class ApplicationDeltaHealthPolicy(_serialization.Model): - """Defines a delta health policy used to evaluate the health of an application or one of its child entities when upgrading the cluster. + """Defines a delta health policy used to evaluate the health of an application or one of its child + entities when upgrading the cluster. :ivar default_service_type_delta_health_policy: The delta health policy used by default to evaluate the health of a service type when upgrading the cluster. @@ -46,8 +47,8 @@ def __init__( *, default_service_type_delta_health_policy: Optional["_models.ServiceTypeDeltaHealthPolicy"] = None, service_type_delta_health_policies: Optional[Dict[str, "_models.ServiceTypeDeltaHealthPolicy"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword default_service_type_delta_health_policy: The delta health policy used by default to evaluate the health of a service type when upgrading the cluster. @@ -64,7 +65,8 @@ def __init__( class ApplicationHealthPolicy(_serialization.Model): - """Defines a health policy used to evaluate the health of an application or one of its children entities. + """Defines a health policy used to evaluate the health of an application or one of its children + entities. :ivar default_service_type_health_policy: The health policy used by default to evaluate the health of a service type. @@ -89,8 +91,8 @@ def __init__( *, default_service_type_health_policy: Optional["_models.ServiceTypeHealthPolicy"] = None, service_type_health_policies: Optional[Dict[str, "_models.ServiceTypeHealthPolicy"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword default_service_type_health_policy: The health policy used by default to evaluate the health of a service type. @@ -107,7 +109,8 @@ def __init__( class ApplicationMetricDescription(_serialization.Model): - """Describes capacity information for a custom resource balancing metric. This can be used to limit the total consumption of this metric by the services of this application. + """Describes capacity information for a custom resource balancing metric. This can be used to + limit the total consumption of this metric by the services of this application. :ivar name: The name of the metric. :vartype name: str @@ -152,8 +155,8 @@ def __init__( maximum_capacity: Optional[int] = None, reservation_capacity: Optional[int] = None, total_application_capacity: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the metric. :paramtype name: str @@ -230,7 +233,7 @@ class ProxyResource(_serialization.Model): "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: It will be deprecated in New API, resource location depends on the parent resource. @@ -349,8 +352,8 @@ def __init__( metrics: Optional[List["_models.ApplicationMetricDescription"]] = None, managed_identities: Optional[List["_models.ApplicationUserAssignedIdentity"]] = None, type_name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: It will be deprecated in New API, resource location depends on the parent resource. @@ -422,7 +425,7 @@ class ApplicationResourceList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.ApplicationResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.ApplicationResource"]] = None, **kwargs: Any) -> None: """ :keyword value: :paramtype value: list[~azure.mgmt.servicefabric.models.ApplicationResource] @@ -489,8 +492,8 @@ def __init__( remove_application_capacity: Optional[bool] = None, metrics: Optional[List["_models.ApplicationMetricDescription"]] = None, managed_identities: Optional[List["_models.ApplicationUserAssignedIdentity"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword type_version: The version of the application type as defined in the application manifest. @@ -598,8 +601,8 @@ def __init__( metrics: Optional[List["_models.ApplicationMetricDescription"]] = None, managed_identities: Optional[List["_models.ApplicationUserAssignedIdentity"]] = None, type_name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword type_version: The version of the application type as defined in the application manifest. @@ -733,8 +736,8 @@ def __init__( remove_application_capacity: Optional[bool] = None, metrics: Optional[List["_models.ApplicationMetricDescription"]] = None, managed_identities: Optional[List["_models.ApplicationUserAssignedIdentity"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: It will be deprecated in New API, resource location depends on the parent resource. @@ -824,7 +827,7 @@ class ApplicationTypeResource(ProxyResource): "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } - def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: It will be deprecated in New API, resource location depends on the parent resource. @@ -856,7 +859,7 @@ class ApplicationTypeResourceList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.ApplicationTypeResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.ApplicationTypeResource"]] = None, **kwargs: Any) -> None: """ :keyword value: :paramtype value: list[~azure.mgmt.servicefabric.models.ApplicationTypeResource] @@ -925,8 +928,8 @@ def __init__( location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, app_package_url: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: It will be deprecated in New API, resource location depends on the parent resource. @@ -943,7 +946,8 @@ def __init__( class ApplicationTypeVersionResourceList(_serialization.Model): - """The list of application type version resources for the specified application type name resource. + """The list of application type version resources for the specified application type name + resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -963,7 +967,9 @@ class ApplicationTypeVersionResourceList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.ApplicationTypeVersionResource"]] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.ApplicationTypeVersionResource"]] = None, **kwargs: Any + ) -> None: """ :keyword value: :paramtype value: list[~azure.mgmt.servicefabric.models.ApplicationTypeVersionResource] @@ -991,7 +997,7 @@ class ApplicationTypeVersionsCleanupPolicy(_serialization.Model): "max_unused_versions_to_keep": {"key": "maxUnusedVersionsToKeep", "type": "int"}, } - def __init__(self, *, max_unused_versions_to_keep: int, **kwargs): + def __init__(self, *, max_unused_versions_to_keep: int, **kwargs: Any) -> None: """ :keyword max_unused_versions_to_keep: Number of unused versions per application type to keep. Required. @@ -1051,8 +1057,8 @@ def __init__( application_health_policy: Optional["_models.ArmApplicationHealthPolicy"] = None, upgrade_mode: Union[str, "_models.RollingUpgradeMode"] = "Monitored", recreate_application: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword upgrade_replica_set_check_timeout: The maximum amount of time to block processing of an upgrade domain and prevent loss of availability when there are unexpected issues. When this @@ -1110,7 +1116,7 @@ class ApplicationUserAssignedIdentity(_serialization.Model): "principal_id": {"key": "principalId", "type": "str"}, } - def __init__(self, *, name: str, principal_id: str, **kwargs): + def __init__(self, *, name: str, principal_id: str, **kwargs: Any) -> None: """ :keyword name: The friendly name of user assigned identity. Required. :paramtype name: str @@ -1123,7 +1129,8 @@ def __init__(self, *, name: str, principal_id: str, **kwargs): class ArmApplicationHealthPolicy(_serialization.Model): - """Defines a health policy used to evaluate the health of an application or one of its children entities. + """Defines a health policy used to evaluate the health of an application or one of its children + entities. :ivar consider_warning_as_error: Indicates whether warnings are treated with the same severity as errors. @@ -1167,8 +1174,8 @@ def __init__( max_percent_unhealthy_deployed_applications: int = 0, default_service_type_health_policy: Optional["_models.ArmServiceTypeHealthPolicy"] = None, service_type_health_policy_map: Optional[Dict[str, "_models.ArmServiceTypeHealthPolicy"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword consider_warning_as_error: Indicates whether warnings are treated with the same severity as errors. @@ -1249,8 +1256,8 @@ def __init__( health_check_retry_timeout: str = "PT0H10M0S", upgrade_timeout: str = "P10675199DT02H48M05.4775807S", upgrade_domain_timeout: str = "P10675199DT02H48M05.4775807S", - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword failure_action: The activation Mode of the service package. Known values are: "Rollback" and "Manual". @@ -1291,7 +1298,8 @@ def __init__( class ArmServiceTypeHealthPolicy(_serialization.Model): - """Represents the health policy used to evaluate the health of services belonging to a service type. + """Represents the health policy used to evaluate the health of services belonging to a service + type. :ivar max_percent_unhealthy_services: The maximum percentage of services allowed to be unhealthy before your application is considered in error. @@ -1328,8 +1336,8 @@ def __init__( max_percent_unhealthy_services: int = 0, max_percent_unhealthy_partitions_per_service: int = 0, max_percent_unhealthy_replicas_per_partition: int = 0, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword max_percent_unhealthy_services: The maximum percentage of services allowed to be unhealthy before your application is considered in error. @@ -1374,8 +1382,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: The name of the provider. :paramtype provider: str @@ -1416,8 +1424,8 @@ def __init__( tenant_id: Optional[str] = None, cluster_application: Optional[str] = None, client_application: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tenant_id: Azure active directory tenant id. :paramtype tenant_id: str @@ -1463,8 +1471,8 @@ def __init__( thumbprint: str, thumbprint_secondary: Optional[str] = None, x509_store_name: Optional[Union[str, "_models.StoreName"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword thumbprint: Thumbprint of the primary certificate. Required. :paramtype thumbprint: str @@ -1507,7 +1515,9 @@ class ClientCertificateCommonName(_serialization.Model): "certificate_issuer_thumbprint": {"key": "certificateIssuerThumbprint", "type": "str"}, } - def __init__(self, *, is_admin: bool, certificate_common_name: str, certificate_issuer_thumbprint: str, **kwargs): + def __init__( + self, *, is_admin: bool, certificate_common_name: str, certificate_issuer_thumbprint: str, **kwargs: Any + ) -> None: """ :keyword is_admin: Indicates if the client certificate has admin access to the cluster. Non admin clients can perform only read only operations on the cluster. Required. @@ -1546,7 +1556,7 @@ class ClientCertificateThumbprint(_serialization.Model): "certificate_thumbprint": {"key": "certificateThumbprint", "type": "str"}, } - def __init__(self, *, is_admin: bool, certificate_thumbprint: str, **kwargs): + def __init__(self, *, is_admin: bool, certificate_thumbprint: str, **kwargs: Any) -> None: """ :keyword is_admin: Indicates if the client certificate has admin access to the cluster. Non admin clients can perform only read only operations on the cluster. Required. @@ -1601,7 +1611,7 @@ class Resource(_serialization.Model): "system_data": {"key": "systemData", "type": "SystemData"}, } - 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 location: Azure resource location. Required. :paramtype location: str @@ -1665,8 +1675,9 @@ class Cluster(Resource): # pylint: disable=too-many-instance-attributes list[~azure.mgmt.servicefabric.models.ClientCertificateThumbprint] :ivar cluster_code_version: The Service Fabric runtime version of the cluster. This property can only by set the user when **upgradeMode** is set to 'Manual'. To get list of available - Service Fabric versions for new clusters use `ClusterVersion API <./ClusterVersion.md>`_. To - get the list of available version for existing clusters use **availableClusterVersions**. + Service Fabric versions for new clusters use `ClusterVersion API + `_. To get the list + of available version for existing clusters use **availableClusterVersions**. :vartype cluster_code_version: str :ivar cluster_endpoint: The Azure Resource Provider endpoint. A system service in the cluster connects to this endpoint. @@ -1878,8 +1889,8 @@ def __init__( # pylint: disable=too-many-locals upgrade_pause_end_timestamp_utc: Optional[datetime.datetime] = None, wave_upgrade_paused: Optional[bool] = None, notifications: Optional[List["_models.Notification"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Azure resource location. Required. :paramtype location: str @@ -1907,8 +1918,9 @@ def __init__( # pylint: disable=too-many-locals list[~azure.mgmt.servicefabric.models.ClientCertificateThumbprint] :keyword cluster_code_version: The Service Fabric runtime version of the cluster. This property can only by set the user when **upgradeMode** is set to 'Manual'. To get list of available - Service Fabric versions for new clusters use `ClusterVersion API <./ClusterVersion.md>`_. To - get the list of available version for existing clusters use **availableClusterVersions**. + Service Fabric versions for new clusters use `ClusterVersion API + `_. To get the list + of available version for existing clusters use **availableClusterVersions**. :paramtype cluster_code_version: str :keyword diagnostics_storage_account_config: The storage account information for storing Service Fabric diagnostic logs. @@ -2036,8 +2048,8 @@ def __init__( *, value: Optional[List["_models.ClusterCodeVersionsResult"]] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: :paramtype value: list[~azure.mgmt.servicefabric.models.ClusterCodeVersionsResult] @@ -2085,8 +2097,8 @@ def __init__( code_version: Optional[str] = None, support_expiry_utc: Optional[str] = None, environment: Optional[Union[str, "_models.ClusterEnvironment"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: The identification of the result. :paramtype id: str @@ -2166,8 +2178,8 @@ def __init__( max_percent_unhealthy_nodes: int = 0, max_percent_unhealthy_applications: int = 0, application_health_policies: Optional[Dict[str, "_models.ApplicationHealthPolicy"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword max_percent_unhealthy_nodes: The maximum allowed percentage of unhealthy nodes before reporting an error. For example, to allow 10% of nodes to be unhealthy, this value would be 10. @@ -2223,7 +2235,9 @@ class ClusterListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.Cluster"]] = None, next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.Cluster"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: :paramtype value: list[~azure.mgmt.servicefabric.models.Cluster] @@ -2260,8 +2274,9 @@ class ClusterUpdateParameters(_serialization.Model): # pylint: disable=too-many list[~azure.mgmt.servicefabric.models.ClientCertificateThumbprint] :ivar cluster_code_version: The Service Fabric runtime version of the cluster. This property can only by set the user when **upgradeMode** is set to 'Manual'. To get list of available - Service Fabric versions for new clusters use `ClusterVersion API <./ClusterVersion.md>`_. To - get the list of available version for existing clusters use **availableClusterVersions**. + Service Fabric versions for new clusters use `ClusterVersion API + `_. To get the list + of available version for existing clusters use **availableClusterVersions**. :vartype cluster_code_version: str :ivar event_store_service_enabled: Indicates if the event store service is enabled. :vartype event_store_service_enabled: bool @@ -2384,8 +2399,8 @@ def __init__( upgrade_pause_end_timestamp_utc: Optional[datetime.datetime] = None, wave_upgrade_paused: Optional[bool] = None, notifications: Optional[List["_models.Notification"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Cluster update parameters. :paramtype tags: dict[str, str] @@ -2409,8 +2424,9 @@ def __init__( list[~azure.mgmt.servicefabric.models.ClientCertificateThumbprint] :keyword cluster_code_version: The Service Fabric runtime version of the cluster. This property can only by set the user when **upgradeMode** is set to 'Manual'. To get list of available - Service Fabric versions for new clusters use `ClusterVersion API <./ClusterVersion.md>`_. To - get the list of available version for existing clusters use **availableClusterVersions**. + Service Fabric versions for new clusters use `ClusterVersion API + `_. To get the list + of available version for existing clusters use **availableClusterVersions**. :paramtype cluster_code_version: str :keyword event_store_service_enabled: Indicates if the event store service is enabled. :paramtype event_store_service_enabled: bool @@ -2558,8 +2574,8 @@ def __init__( max_percent_upgrade_domain_delta_unhealthy_nodes: int, max_percent_delta_unhealthy_applications: int, application_delta_health_policies: Optional[Dict[str, "_models.ApplicationDeltaHealthPolicy"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword max_percent_delta_unhealthy_nodes: The maximum allowed percentage of nodes health degradation allowed during cluster upgrades. @@ -2668,8 +2684,8 @@ def __init__( health_policy: "_models.ClusterHealthPolicy", force_restart: Optional[bool] = None, delta_health_policy: Optional["_models.ClusterUpgradeDeltaHealthPolicy"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword force_restart: If true, then processes are forcefully restarted during upgrade even when the code version has not changed (the upgrade only changes configuration or data). @@ -2741,8 +2757,8 @@ def __init__( code_version: Optional[str] = None, support_expiry_utc: Optional[str] = None, environment: Optional[Union[str, "_models.ClusterEnvironment"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword code_version: The Service Fabric runtime version of the cluster. :paramtype code_version: str @@ -2804,8 +2820,8 @@ def __init__( queue_endpoint: str, table_endpoint: str, protected_account_key_name2: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword storage_account_name: The Azure storage account name. Required. :paramtype storage_account_name: str @@ -2851,7 +2867,7 @@ class EndpointRangeDescription(_serialization.Model): "end_port": {"key": "endPort", "type": "int"}, } - def __init__(self, *, start_port: int, end_port: int, **kwargs): + def __init__(self, *, start_port: int, end_port: int, **kwargs: Any) -> None: """ :keyword start_port: Starting port of a range of ports. Required. :paramtype start_port: int @@ -2874,7 +2890,7 @@ class ErrorModel(_serialization.Model): "error": {"key": "error", "type": "ErrorModelError"}, } - def __init__(self, *, error: Optional["_models.ErrorModelError"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorModelError"] = None, **kwargs: Any) -> None: """ :keyword error: The error details. :paramtype error: ~azure.mgmt.servicefabric.models.ErrorModelError @@ -2897,7 +2913,7 @@ class ErrorModelError(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: The error code. :paramtype code: str @@ -2947,8 +2963,8 @@ def __init__( *, type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword type: The type of managed identity for the resource. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". @@ -2996,10 +3012,10 @@ class PartitionSchemeDescription(_serialization.Model): } } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.partition_scheme = None # type: Optional[str] + self.partition_scheme: Optional[str] = None class NamedPartitionSchemeDescription(PartitionSchemeDescription): @@ -3029,7 +3045,7 @@ class NamedPartitionSchemeDescription(PartitionSchemeDescription): "names": {"key": "names", "type": "[str]"}, } - def __init__(self, *, count: int, names: List[str], **kwargs): + def __init__(self, *, count: int, names: List[str], **kwargs: Any) -> None: """ :keyword count: The number of partitions. Required. :paramtype count: int @@ -3038,13 +3054,14 @@ def __init__(self, *, count: int, names: List[str], **kwargs): :paramtype names: list[str] """ super().__init__(**kwargs) - self.partition_scheme = "Named" # type: str + self.partition_scheme: str = "Named" self.count = count self.names = names class NodeTypeDescription(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Describes a node type in the cluster, each node type represents sub set of nodes in the cluster. + """Describes a node type in the cluster, each node type represents sub set of nodes in the + cluster. All required parameters must be populated in order to send to Azure. @@ -3135,8 +3152,8 @@ def __init__( reverse_proxy_endpoint_port: Optional[int] = None, is_stateless: Optional[bool] = None, multiple_availability_zones: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the node type. Required. :paramtype name: str @@ -3237,8 +3254,8 @@ def __init__( notification_category: Union[str, "_models.NotificationCategory"], notification_level: Union[str, "_models.NotificationLevel"], notification_targets: List["_models.NotificationTarget"], - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword is_enabled: Indicates if the notification is enabled. Required. :paramtype is_enabled: bool @@ -3281,8 +3298,8 @@ class NotificationTarget(_serialization.Model): } def __init__( - self, *, notification_channel: Union[str, "_models.NotificationChannel"], receivers: List[str], **kwargs - ): + self, *, notification_channel: Union[str, "_models.NotificationChannel"], receivers: List[str], **kwargs: Any + ) -> None: """ :keyword notification_channel: The notification channel indicates the type of receivers subscribed to the notification, either user or subscription. Required. Known values are: @@ -3316,7 +3333,7 @@ class OperationListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.OperationResult"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.OperationResult"]] = None, **kwargs: Any) -> None: """ :keyword value: List of operations supported by the Service Fabric resource provider. :paramtype value: list[~azure.mgmt.servicefabric.models.OperationResult] @@ -3357,8 +3374,8 @@ def __init__( display: Optional["_models.AvailableOperationDisplay"] = None, origin: Optional[str] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the operation. :paramtype name: str @@ -3400,7 +3417,7 @@ class ServerCertificateCommonName(_serialization.Model): "certificate_issuer_thumbprint": {"key": "certificateIssuerThumbprint", "type": "str"}, } - def __init__(self, *, certificate_common_name: str, certificate_issuer_thumbprint: str, **kwargs): + def __init__(self, *, certificate_common_name: str, certificate_issuer_thumbprint: str, **kwargs: Any) -> None: """ :keyword certificate_common_name: The common name of the server certificate. Required. :paramtype certificate_common_name: str @@ -3414,7 +3431,8 @@ def __init__(self, *, certificate_common_name: str, certificate_issuer_thumbprin class ServerCertificateCommonNames(_serialization.Model): - """Describes a list of server certificates referenced by common name that are used to secure the cluster. + """Describes a list of server certificates referenced by common name that are used to secure the + cluster. :ivar common_names: The list of server certificates referenced by common name that are used to secure the cluster. @@ -3435,8 +3453,8 @@ def __init__( *, common_names: Optional[List["_models.ServerCertificateCommonName"]] = None, x509_store_name: Optional[Union[str, "_models.StoreName"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword common_names: The list of server certificates referenced by common name that are used to secure the cluster. @@ -3475,7 +3493,9 @@ class ServiceCorrelationDescription(_serialization.Model): "service_name": {"key": "serviceName", "type": "str"}, } - def __init__(self, *, scheme: Union[str, "_models.ServiceCorrelationScheme"], service_name: str, **kwargs): + def __init__( + self, *, scheme: Union[str, "_models.ServiceCorrelationScheme"], service_name: str, **kwargs: Any + ) -> None: """ :keyword scheme: The ServiceCorrelationScheme which describes the relationship between this service and the service specified via ServiceName. Required. Known values are: "Invalid", @@ -3533,8 +3553,8 @@ def __init__( primary_default_load: Optional[int] = None, secondary_default_load: Optional[int] = None, default_load: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the metric. If the service chooses to report load during runtime, the load metric name should match the name that is specified in Name exactly. Note that metric @@ -3580,10 +3600,10 @@ class ServicePlacementPolicyDescription(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.type = None # type: Optional[str] + self.type: Optional[str] = None class ServiceResource(ProxyResource): # pylint: disable=too-many-instance-attributes @@ -3692,8 +3712,8 @@ def __init__( partition_description: Optional["_models.PartitionSchemeDescription"] = None, service_package_activation_mode: Optional[Union[str, "_models.ArmServicePackageActivationMode"]] = None, service_dns_name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: It will be deprecated in New API, resource location depends on the parent resource. @@ -3739,7 +3759,7 @@ def __init__( self.service_placement_policies = service_placement_policies self.default_move_cost = default_move_cost self.provisioning_state = None - self.service_kind = None # type: Optional[str] + self.service_kind: Optional[str] = None self.service_type_name = service_type_name self.partition_description = partition_description self.service_package_activation_mode = service_package_activation_mode @@ -3766,7 +3786,7 @@ class ServiceResourceList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.ServiceResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.ServiceResource"]] = None, **kwargs: Any) -> None: """ :keyword value: :paramtype value: list[~azure.mgmt.servicefabric.models.ServiceResource] @@ -3820,8 +3840,8 @@ def __init__( service_load_metrics: Optional[List["_models.ServiceLoadMetricDescription"]] = None, service_placement_policies: Optional[List["_models.ServicePlacementPolicyDescription"]] = None, default_move_cost: Optional[Union[str, "_models.MoveCost"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword placement_constraints: The placement constraints as a string. Placement constraints are boolean expressions on node properties and allow for restricting a service to particular @@ -3939,8 +3959,8 @@ def __init__( partition_description: Optional["_models.PartitionSchemeDescription"] = None, service_package_activation_mode: Optional[Union[str, "_models.ArmServicePackageActivationMode"]] = None, service_dns_name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword placement_constraints: The placement constraints as a string. Placement constraints are boolean expressions on node properties and allow for restricting a service to particular @@ -3983,7 +4003,7 @@ def __init__( **kwargs ) self.provisioning_state = None - self.service_kind = None # type: Optional[str] + self.service_kind: Optional[str] = None self.service_type_name = service_type_name self.partition_description = partition_description self.service_package_activation_mode = service_package_activation_mode @@ -4072,8 +4092,8 @@ def __init__( service_load_metrics: Optional[List["_models.ServiceLoadMetricDescription"]] = None, service_placement_policies: Optional[List["_models.ServicePlacementPolicyDescription"]] = None, default_move_cost: Optional[Union[str, "_models.MoveCost"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: It will be deprecated in New API, resource location depends on the parent resource. @@ -4107,7 +4127,7 @@ def __init__( self.service_load_metrics = service_load_metrics self.service_placement_policies = service_placement_policies self.default_move_cost = default_move_cost - self.service_kind = None # type: Optional[str] + self.service_kind: Optional[str] = None class ServiceResourceUpdateProperties(ServiceResourcePropertiesBase): @@ -4171,8 +4191,8 @@ def __init__( service_load_metrics: Optional[List["_models.ServiceLoadMetricDescription"]] = None, service_placement_policies: Optional[List["_models.ServicePlacementPolicyDescription"]] = None, default_move_cost: Optional[Union[str, "_models.MoveCost"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword placement_constraints: The placement constraints as a string. Placement constraints are boolean expressions on node properties and allow for restricting a service to particular @@ -4203,11 +4223,12 @@ def __init__( default_move_cost=default_move_cost, **kwargs ) - self.service_kind = None # type: Optional[str] + self.service_kind: Optional[str] = None class ServiceTypeDeltaHealthPolicy(_serialization.Model): - """Represents the delta health policy used to evaluate the health of services belonging to a service type when upgrading the cluster. + """Represents the delta health policy used to evaluate the health of services belonging to a + service type when upgrading the cluster. :ivar max_percent_delta_unhealthy_services: The maximum allowed percentage of services health degradation allowed during cluster upgrades. @@ -4226,7 +4247,7 @@ class ServiceTypeDeltaHealthPolicy(_serialization.Model): "max_percent_delta_unhealthy_services": {"key": "maxPercentDeltaUnhealthyServices", "type": "int"}, } - def __init__(self, *, max_percent_delta_unhealthy_services: int = 0, **kwargs): + def __init__(self, *, max_percent_delta_unhealthy_services: int = 0, **kwargs: Any) -> None: """ :keyword max_percent_delta_unhealthy_services: The maximum allowed percentage of services health degradation allowed during cluster upgrades. @@ -4241,7 +4262,8 @@ def __init__(self, *, max_percent_delta_unhealthy_services: int = 0, **kwargs): class ServiceTypeHealthPolicy(_serialization.Model): - """Represents the health policy used to evaluate the health of services belonging to a service type. + """Represents the health policy used to evaluate the health of services belonging to a service + type. :ivar max_percent_unhealthy_services: The maximum percentage of services allowed to be unhealthy before your application is considered in error. @@ -4256,7 +4278,7 @@ class ServiceTypeHealthPolicy(_serialization.Model): "max_percent_unhealthy_services": {"key": "maxPercentUnhealthyServices", "type": "int"}, } - def __init__(self, *, max_percent_unhealthy_services: int = 0, **kwargs): + def __init__(self, *, max_percent_unhealthy_services: int = 0, **kwargs: Any) -> None: """ :keyword max_percent_unhealthy_services: The maximum percentage of services allowed to be unhealthy before your application is considered in error. @@ -4287,7 +4309,7 @@ class SettingsParameterDescription(_serialization.Model): "value": {"key": "value", "type": "str"}, } - def __init__(self, *, name: str, value: str, **kwargs): + def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: """ :keyword name: The parameter name of fabric setting. Required. :paramtype name: str @@ -4320,7 +4342,7 @@ class SettingsSectionDescription(_serialization.Model): "parameters": {"key": "parameters", "type": "[SettingsParameterDescription]"}, } - def __init__(self, *, name: str, parameters: List["_models.SettingsParameterDescription"], **kwargs): + def __init__(self, *, name: str, parameters: List["_models.SettingsParameterDescription"], **kwargs: Any) -> None: """ :keyword name: The section name of the fabric settings. Required. :paramtype name: str @@ -4350,10 +4372,10 @@ class SingletonPartitionSchemeDescription(PartitionSchemeDescription): "partition_scheme": {"key": "partitionScheme", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.partition_scheme = "Singleton" # type: str + self.partition_scheme: str = "Singleton" class StatefulServiceProperties(ServiceResourceProperties): # pylint: disable=too-many-instance-attributes @@ -4466,8 +4488,8 @@ def __init__( replica_restart_wait_duration: Optional[datetime.datetime] = None, quorum_loss_wait_duration: Optional[datetime.datetime] = None, stand_by_replica_keep_duration: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword placement_constraints: The placement constraints as a string. Placement constraints are boolean expressions on node properties and allow for restricting a service to particular @@ -4530,7 +4552,7 @@ def __init__( service_dns_name=service_dns_name, **kwargs ) - self.service_kind = "Stateful" # type: str + self.service_kind: str = "Stateful" self.has_persisted_state = has_persisted_state self.target_replica_set_size = target_replica_set_size self.min_replica_set_size = min_replica_set_size @@ -4618,8 +4640,8 @@ def __init__( replica_restart_wait_duration: Optional[datetime.datetime] = None, quorum_loss_wait_duration: Optional[datetime.datetime] = None, stand_by_replica_keep_duration: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword placement_constraints: The placement constraints as a string. Placement constraints are boolean expressions on node properties and allow for restricting a service to particular @@ -4663,7 +4685,7 @@ def __init__( default_move_cost=default_move_cost, **kwargs ) - self.service_kind = "Stateful" # type: str + self.service_kind: str = "Stateful" self.target_replica_set_size = target_replica_set_size self.min_replica_set_size = min_replica_set_size self.replica_restart_wait_duration = replica_restart_wait_duration @@ -4765,8 +4787,8 @@ def __init__( service_dns_name: Optional[str] = None, instance_count: Optional[int] = None, instance_close_delay_duration: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword placement_constraints: The placement constraints as a string. Placement constraints are boolean expressions on node properties and allow for restricting a service to particular @@ -4821,7 +4843,7 @@ def __init__( service_dns_name=service_dns_name, **kwargs ) - self.service_kind = "Stateless" # type: str + self.service_kind: str = "Stateless" self.instance_count = instance_count self.instance_close_delay_duration = instance_close_delay_duration @@ -4895,8 +4917,8 @@ def __init__( default_move_cost: Optional[Union[str, "_models.MoveCost"]] = None, instance_count: Optional[int] = None, instance_close_delay_duration: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword placement_constraints: The placement constraints as a string. Placement constraints are boolean expressions on node properties and allow for restricting a service to particular @@ -4937,7 +4959,7 @@ def __init__( default_move_cost=default_move_cost, **kwargs ) - self.service_kind = "Stateless" # type: str + self.service_kind: str = "Stateless" self.instance_count = instance_count self.instance_close_delay_duration = instance_close_delay_duration @@ -4977,8 +4999,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[str] = 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 @@ -5003,7 +5025,8 @@ def __init__( class UniformInt64RangePartitionSchemeDescription(PartitionSchemeDescription): - """Describes a partitioning scheme where an integer range is allocated evenly across a number of partitions. + """Describes a partitioning scheme where an integer range is allocated evenly across a number of + partitions. All required parameters must be populated in order to send to Azure. @@ -5034,7 +5057,7 @@ class UniformInt64RangePartitionSchemeDescription(PartitionSchemeDescription): "high_key": {"key": "highKey", "type": "str"}, } - def __init__(self, *, count: int, low_key: str, high_key: str, **kwargs): + def __init__(self, *, count: int, low_key: str, high_key: str, **kwargs: Any) -> None: """ :keyword count: The number of partitions. Required. :paramtype count: int @@ -5046,14 +5069,15 @@ def __init__(self, *, count: int, low_key: str, high_key: str, **kwargs): :paramtype high_key: str """ super().__init__(**kwargs) - self.partition_scheme = "UniformInt64Range" # type: str + self.partition_scheme: str = "UniformInt64Range" self.count = count self.low_key = low_key self.high_key = high_key class UpgradableVersionPathResult(_serialization.Model): - """The list of intermediate cluster code versions for an upgrade or downgrade. Or minimum and maximum upgradable version if no target was given. + """The list of intermediate cluster code versions for an upgrade or downgrade. Or minimum and + maximum upgradable version if no target was given. :ivar supported_path: :vartype supported_path: list[str] @@ -5063,7 +5087,7 @@ class UpgradableVersionPathResult(_serialization.Model): "supported_path": {"key": "supportedPath", "type": "[str]"}, } - def __init__(self, *, supported_path: Optional[List[str]] = None, **kwargs): + def __init__(self, *, supported_path: Optional[List[str]] = None, **kwargs: Any) -> None: """ :keyword supported_path: :paramtype supported_path: list[str] @@ -5089,7 +5113,7 @@ class UpgradableVersionsDescription(_serialization.Model): "target_version": {"key": "targetVersion", "type": "str"}, } - def __init__(self, *, target_version: str, **kwargs): + def __init__(self, *, target_version: str, **kwargs: Any) -> None: """ :keyword target_version: The target code version. Required. :paramtype target_version: str @@ -5119,7 +5143,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 diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/models/_service_fabric_management_client_enums.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/models/_service_fabric_management_client_enums.py index fee26c394fbc..97166902f3d2 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/models/_service_fabric_management_client_enums.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/models/_service_fabric_management_client_enums.py @@ -22,21 +22,21 @@ class AddOnFeatures(str, Enum, metaclass=CaseInsensitiveEnumMeta): class ArmServicePackageActivationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The activation Mode of the service package.""" - #: Indicates the application package activation mode will use shared process. SHARED_PROCESS = "SharedProcess" - #: Indicates the application package activation mode will use exclusive process. + """Indicates the application package activation mode will use shared process.""" EXCLUSIVE_PROCESS = "ExclusiveProcess" + """Indicates the application package activation mode will use exclusive process.""" class ArmUpgradeFailureAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The activation Mode of the service package.""" - #: Indicates that a rollback of the upgrade will be performed by Service Fabric if the upgrade - #: fails. ROLLBACK = "Rollback" - #: Indicates that a manual repair will need to be performed by the administrator if the upgrade - #: fails. Service Fabric will not proceed to the next upgrade domain automatically. + """Indicates that a rollback of the upgrade will be performed by Service Fabric if the upgrade + #: fails.""" MANUAL = "Manual" + """Indicates that a manual repair will need to be performed by the administrator if the upgrade + #: fails. Service Fabric will not proceed to the next upgrade domain automatically.""" class ClusterEnvironment(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -88,15 +88,15 @@ class ClusterUpgradeCadence(str, Enum, metaclass=CaseInsensitiveEnumMeta): default is Wave0. """ - #: Cluster upgrade starts immediately after a new version is rolled out. Recommended for Test/Dev - #: clusters. WAVE0 = "Wave0" - #: Cluster upgrade starts 7 days after a new version is rolled out. Recommended for Pre-prod - #: clusters. + """Cluster upgrade starts immediately after a new version is rolled out. Recommended for Test/Dev + #: clusters.""" WAVE1 = "Wave1" - #: Cluster upgrade starts 14 days after a new version is rolled out. Recommended for Production - #: clusters. + """Cluster upgrade starts 7 days after a new version is rolled out. Recommended for Pre-prod + #: clusters.""" WAVE2 = "Wave2" + """Cluster upgrade starts 14 days after a new version is rolled out. Recommended for Production + #: clusters.""" class ClusterVersionsEnvironment(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -125,35 +125,35 @@ class DurabilityLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of managed identity for the resource.""" - #: Indicates that system assigned identity is associated with the resource. SYSTEM_ASSIGNED = "SystemAssigned" - #: Indicates that user assigned identity is associated with the resource. + """Indicates that system assigned identity is associated with the resource.""" USER_ASSIGNED = "UserAssigned" - #: Indicates that both system assigned and user assigned identity are associated with the - #: resource. + """Indicates that user assigned identity is associated with the resource.""" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" - #: Indicates that no identity is associated with the resource. + """Indicates that both system assigned and user assigned identity are associated with the + #: resource.""" NONE = "None" + """Indicates that no identity is associated with the resource.""" class MoveCost(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the move cost for the service.""" - #: Zero move cost. This value is zero. ZERO = "Zero" - #: Specifies the move cost of the service as Low. The value is 1. + """Zero move cost. This value is zero.""" LOW = "Low" - #: Specifies the move cost of the service as Medium. The value is 2. + """Specifies the move cost of the service as Low. The value is 1.""" MEDIUM = "Medium" - #: Specifies the move cost of the service as High. The value is 3. + """Specifies the move cost of the service as Medium. The value is 2.""" HIGH = "High" + """Specifies the move cost of the service as High. The value is 3.""" class NotificationCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The category of notification.""" - #: Notification will be regarding wave progress. WAVE_PROGRESS = "WaveProgress" + """Notification will be regarding wave progress.""" class NotificationChannel(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -161,39 +161,39 @@ class NotificationChannel(str, Enum, metaclass=CaseInsensitiveEnumMeta): user or subscription. """ - #: For email user receivers. In this case, the parameter receivers should be a list of email - #: addresses that will receive the notifications. EMAIL_USER = "EmailUser" - #: For subscription receivers. In this case, the parameter receivers should be a list of roles of - #: the subscription for the cluster (eg. Owner, AccountAdmin, etc) that will receive the - #: notifications. + """For email user receivers. In this case, the parameter receivers should be a list of email + #: addresses that will receive the notifications.""" EMAIL_SUBSCRIPTION = "EmailSubscription" + """For subscription receivers. In this case, the parameter receivers should be a list of roles of + #: the subscription for the cluster (eg. Owner, AccountAdmin, etc) that will receive the + #: notifications.""" class NotificationLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level of notification.""" - #: Receive only critical notifications. CRITICAL = "Critical" - #: Receive all notifications. + """Receive only critical notifications.""" ALL = "All" + """Receive all notifications.""" class PartitionScheme(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Enumerates the ways that a service can be partitioned.""" - #: Indicates the partition kind is invalid. All Service Fabric enumerations have the invalid type. - #: The value is zero. INVALID = "Invalid" - #: Indicates that the partition is based on string names, and is a - #: SingletonPartitionSchemeDescription object, The value is 1. + """Indicates the partition kind is invalid. All Service Fabric enumerations have the invalid type. + #: The value is zero.""" SINGLETON = "Singleton" - #: Indicates that the partition is based on Int64 key ranges, and is a - #: UniformInt64RangePartitionSchemeDescription object. The value is 2. + """Indicates that the partition is based on string names, and is a + #: SingletonPartitionSchemeDescription object, The value is 1.""" UNIFORM_INT64_RANGE = "UniformInt64Range" - #: Indicates that the partition is based on string names, and is a NamedPartitionSchemeDescription - #: object. The value is 3 + """Indicates that the partition is based on Int64 key ranges, and is a + #: UniformInt64RangePartitionSchemeDescription object. The value is 2.""" NAMED = "Named" + """Indicates that the partition is based on string names, and is a NamedPartitionSchemeDescription + #: object. The value is 3""" class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -232,49 +232,49 @@ class RollingUpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): UnmonitoredManual, and Monitored. """ - #: Indicates the upgrade mode is invalid. All Service Fabric enumerations have the invalid type. - #: The value is zero. INVALID = "Invalid" - #: The upgrade will proceed automatically without performing any health monitoring. The value is 1 + """Indicates the upgrade mode is invalid. All Service Fabric enumerations have the invalid type. + #: The value is zero.""" UNMONITORED_AUTO = "UnmonitoredAuto" - #: The upgrade will stop after completing each upgrade domain, giving the opportunity to manually - #: monitor health before proceeding. The value is 2 + """The upgrade will proceed automatically without performing any health monitoring. The value is 1""" UNMONITORED_MANUAL = "UnmonitoredManual" - #: The upgrade will stop after completing each upgrade domain and automatically monitor health - #: before proceeding. The value is 3 + """The upgrade will stop after completing each upgrade domain, giving the opportunity to manually + #: monitor health before proceeding. The value is 2""" MONITORED = "Monitored" + """The upgrade will stop after completing each upgrade domain and automatically monitor health + #: before proceeding. The value is 3""" class ServiceCorrelationScheme(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The service correlation scheme.""" - #: An invalid correlation scheme. Cannot be used. The value is zero. INVALID = "Invalid" - #: Indicates that this service has an affinity relationship with another service. Provided for - #: backwards compatibility, consider preferring the Aligned or NonAlignedAffinity options. The - #: value is 1. + """An invalid correlation scheme. Cannot be used. The value is zero.""" AFFINITY = "Affinity" - #: Aligned affinity ensures that the primaries of the partitions of the affinitized services are - #: collocated on the same nodes. This is the default and is the same as selecting the Affinity - #: scheme. The value is 2. + """Indicates that this service has an affinity relationship with another service. Provided for + #: backwards compatibility, consider preferring the Aligned or NonAlignedAffinity options. The + #: value is 1.""" ALIGNED_AFFINITY = "AlignedAffinity" - #: Non-Aligned affinity guarantees that all replicas of each service will be placed on the same - #: nodes. Unlike Aligned Affinity, this does not guarantee that replicas of particular role will - #: be collocated. The value is 3. + """Aligned affinity ensures that the primaries of the partitions of the affinitized services are + #: collocated on the same nodes. This is the default and is the same as selecting the Affinity + #: scheme. The value is 2.""" NON_ALIGNED_AFFINITY = "NonAlignedAffinity" + """Non-Aligned affinity guarantees that all replicas of each service will be placed on the same + #: nodes. Unlike Aligned Affinity, this does not guarantee that replicas of particular role will + #: be collocated. The value is 3.""" class ServiceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The kind of service (Stateless or Stateful).""" - #: Indicates the service kind is invalid. All Service Fabric enumerations have the invalid type. - #: The value is zero. INVALID = "Invalid" - #: Does not use Service Fabric to make its state highly available or reliable. The value is 1. + """Indicates the service kind is invalid. All Service Fabric enumerations have the invalid type. + #: The value is zero.""" STATELESS = "Stateless" - #: Uses Service Fabric to make its state or part of its state highly available and reliable. The - #: value is 2. + """Does not use Service Fabric to make its state highly available or reliable. The value is 1.""" STATEFUL = "Stateful" + """Uses Service Fabric to make its state or part of its state highly available and reliable. The + #: value is 2.""" class ServiceLoadMetricWeight(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -283,44 +283,44 @@ class ServiceLoadMetricWeight(str, Enum, metaclass=CaseInsensitiveEnumMeta): prefers the metric with the higher weight. """ - #: Disables resource balancing for this metric. This value is zero. ZERO = "Zero" - #: Specifies the metric weight of the service load as Low. The value is 1. + """Disables resource balancing for this metric. This value is zero.""" LOW = "Low" - #: Specifies the metric weight of the service load as Medium. The value is 2. + """Specifies the metric weight of the service load as Low. The value is 1.""" MEDIUM = "Medium" - #: Specifies the metric weight of the service load as High. The value is 3. + """Specifies the metric weight of the service load as Medium. The value is 2.""" HIGH = "High" + """Specifies the metric weight of the service load as High. The value is 3.""" class ServicePlacementPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of placement policy for a service fabric service. Following are the possible values.""" - #: Indicates the type of the placement policy is invalid. All Service Fabric enumerations have the - #: invalid type. The value is zero. INVALID = "Invalid" - #: Indicates that the ServicePlacementPolicyDescription is of type - #: ServicePlacementInvalidDomainPolicyDescription, which indicates that a particular fault or - #: upgrade domain cannot be used for placement of this service. The value is 1. + """Indicates the type of the placement policy is invalid. All Service Fabric enumerations have the + #: invalid type. The value is zero.""" INVALID_DOMAIN = "InvalidDomain" - #: Indicates that the ServicePlacementPolicyDescription is of type - #: ServicePlacementRequireDomainDistributionPolicyDescription indicating that the replicas of the - #: service must be placed in a specific domain. The value is 2. + """Indicates that the ServicePlacementPolicyDescription is of type + #: ServicePlacementInvalidDomainPolicyDescription, which indicates that a particular fault or + #: upgrade domain cannot be used for placement of this service. The value is 1.""" REQUIRED_DOMAIN = "RequiredDomain" - #: Indicates that the ServicePlacementPolicyDescription is of type + """Indicates that the ServicePlacementPolicyDescription is of type + #: ServicePlacementRequireDomainDistributionPolicyDescription indicating that the replicas of the + #: service must be placed in a specific domain. The value is 2.""" + PREFERRED_PRIMARY_DOMAIN = "PreferredPrimaryDomain" + """Indicates that the ServicePlacementPolicyDescription is of type #: ServicePlacementPreferPrimaryDomainPolicyDescription, which indicates that if possible the #: Primary replica for the partitions of the service should be located in a particular domain as - #: an optimization. The value is 3. - PREFERRED_PRIMARY_DOMAIN = "PreferredPrimaryDomain" - #: Indicates that the ServicePlacementPolicyDescription is of type + #: an optimization. The value is 3.""" + REQUIRED_DOMAIN_DISTRIBUTION = "RequiredDomainDistribution" + """Indicates that the ServicePlacementPolicyDescription is of type #: ServicePlacementRequireDomainDistributionPolicyDescription, indicating that the system will #: disallow placement of any two replicas from the same partition in the same domain at any time. - #: The value is 4. - REQUIRED_DOMAIN_DISTRIBUTION = "RequiredDomainDistribution" - #: Indicates that the ServicePlacementPolicyDescription is of type - #: ServicePlacementNonPartiallyPlaceServicePolicyDescription, which indicates that if possible all - #: replicas of a particular partition of the service should be placed atomically. The value is 5. + #: The value is 4.""" NON_PARTIALLY_PLACE_SERVICE = "NonPartiallyPlaceService" + """Indicates that the ServicePlacementPolicyDescription is of type + #: ServicePlacementNonPartiallyPlaceServicePolicyDescription, which indicates that if possible all + #: replicas of a particular partition of the service should be placed atomically. The value is 5.""" class SfZonalUpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -329,16 +329,16 @@ class SfZonalUpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): cluster. """ - #: VMs under the node type are grouped into UDs and ignore the zone info in five UDs. This setting + PARALLEL = "Parallel" + """VMs under the node type are grouped into UDs and ignore the zone info in five UDs. This setting #: causes UDs across all zones to be upgraded at the same time. This deployment mode is faster for #: upgrades, we don't recommend it because it goes against the SDP guidelines, which state that - #: the updates should be applied to one zone at a time. - PARALLEL = "Parallel" - #: If this value is omitted or set to Hierarchical, VMs are grouped to reflect the zonal + #: the updates should be applied to one zone at a time.""" + HIERARCHICAL = "Hierarchical" + """If this value is omitted or set to Hierarchical, VMs are grouped to reflect the zonal #: distribution in up to 15 UDs. Each of the three zones has five UDs. This ensures that the zones #: are updated one at a time, moving to next zone only after completing five UDs within the first - #: zone. This update process is safer for the cluster and the user application. - HIERARCHICAL = "Hierarchical" + #: zone. This update process is safer for the cluster and the user application.""" class StoreName(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -357,12 +357,12 @@ class StoreName(str, Enum, metaclass=CaseInsensitiveEnumMeta): class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The upgrade mode of the cluster when new Service Fabric runtime version is available.""" - #: The cluster will be automatically upgraded to the latest Service Fabric runtime version, - #: **upgradeWave** will determine when the upgrade starts after the new version becomes available. AUTOMATIC = "Automatic" - #: The cluster will not be automatically upgraded to the latest Service Fabric runtime version. - #: The cluster is upgraded by setting the **clusterCodeVersion** property in the cluster resource. + """The cluster will be automatically upgraded to the latest Service Fabric runtime version, + #: **upgradeWave** will determine when the upgrade starts after the new version becomes available.""" MANUAL = "Manual" + """The cluster will not be automatically upgraded to the latest Service Fabric runtime version. + #: The cluster is upgraded by setting the **clusterCodeVersion** property in the cluster resource.""" class VmssZonalUpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -370,9 +370,9 @@ class VmssZonalUpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): node type with multiple Availability Zones is added. """ - #: Updates will happen in all Availability Zones at once for the virtual machine scale sets. PARALLEL = "Parallel" - #: VMs are grouped to reflect the zonal distribution in up to 15 UDs. Each of the three zones has - #: five UDs. This ensures that the zones are updated one at a time, moving to next zone only after - #: completing five UDs within the first zone. + """Updates will happen in all Availability Zones at once for the virtual machine scale sets.""" HIERARCHICAL = "Hierarchical" + """VMs are grouped to reflect the zonal distribution in up to 15 UDs. Each of the three zones has + #: five UDs. This ensures that the zones are updated one at a time, moving to next zone only after + #: completing five UDs within the first zone.""" diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/__init__.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/__init__.py index 69103382d011..aa1919dd5f64 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/__init__.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/__init__.py @@ -15,7 +15,7 @@ from ._services_operations import ServicesOperations 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/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_application_type_versions_operations.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_application_type_versions_operations.py index f078031660a2..624614fc2cc2 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_application_type_versions_operations.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_application_type_versions_operations.py @@ -6,8 +6,9 @@ # 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, IO, Optional, TypeVar, Union, cast, overload +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,6 +18,7 @@ ResourceNotModifiedError, map_error, ) +from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod @@ -28,12 +30,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +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]] @@ -52,7 +50,7 @@ def build_get_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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +66,7 @@ def build_get_request( "version": _SERIALIZER.url("version", version, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,8 +88,8 @@ def build_create_or_update_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", "2021-06-01")) # type: Literal["2021-06-01"] - 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", "2021-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +105,7 @@ def build_create_or_update_request( "version": _SERIALIZER.url("version", version, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -131,7 +129,7 @@ def build_delete_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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -147,7 +145,7 @@ def build_delete_request( "version": _SERIALIZER.url("version", version, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -164,7 +162,7 @@ def build_list_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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -179,7 +177,7 @@ def build_list_request( "applicationTypeName": _SERIALIZER.url("application_type_name", application_type_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -242,10 +240,8 @@ def get( _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationTypeVersionResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplicationTypeVersionResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -259,10 +255,11 @@ def get( 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 @@ -279,7 +276,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}" + } def _create_or_update_initial( self, @@ -301,16 +300,14 @@ def _create_or_update_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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationTypeVersionResource] + 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.ApplicationTypeVersionResource] = 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, "ApplicationTypeVersionResource") @@ -330,10 +327,11 @@ def _create_or_update_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 @@ -350,7 +348,9 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}" + } @overload def begin_create_or_update( @@ -462,8 +462,8 @@ def begin_create_or_update( :type application_type_name: str :param version: The application type version. Required. :type version: str - :param parameters: The application type version resource. Is either a model type or a IO type. - Required. + :param parameters: The application type version resource. Is either a + ApplicationTypeVersionResource type or a IO type. Required. :type parameters: ~azure.mgmt.servicefabric.models.ApplicationTypeVersionResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -485,16 +485,14 @@ def begin_create_or_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationTypeVersionResource] - 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.ApplicationTypeVersionResource] = 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_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, application_type_name=application_type_name, @@ -516,7 +514,7 @@ def get_long_running_output(pipeline_response): return deserialized 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: @@ -528,9 +526,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_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, application_type_name: str, version: str, **kwargs: Any @@ -546,10 +546,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["2021-06-01"] - 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, @@ -563,10 +561,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 @@ -579,7 +578,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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}" + } @distributed_trace def begin_delete( @@ -612,13 +613,11 @@ def begin_delete( _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["2021-06-01"] - 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, @@ -638,7 +637,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: @@ -650,14 +649,16 @@ 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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}" + } @distributed_trace def list( self, resource_group_name: str, cluster_name: str, application_type_name: str, **kwargs: Any - ) -> _models.ApplicationTypeVersionResourceList: + ) -> Iterable["_models.ApplicationTypeVersionResource"]: """Gets the list of application type version resources created in the specified Service Fabric application type name resource. @@ -671,10 +672,18 @@ def list( :param application_type_name: The name of the application type name resource. Required. :type application_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationTypeVersionResourceList or the result of cls(response) - :rtype: ~azure.mgmt.servicefabric.models.ApplicationTypeVersionResourceList + :return: An iterator like instance of either ApplicationTypeVersionResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicefabric.models.ApplicationTypeVersionResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplicationTypeVersionResourceList] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -683,43 +692,65 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationTypeVersionResourceList] - - request = build_list_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - application_type_name=application_type_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.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 - ) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + application_type_name=application_type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationTypeVersionResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("ApplicationTypeVersionResourceList", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions" + } diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_application_types_operations.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_application_types_operations.py index 840c79d17a2c..e5289dfb520d 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_application_types_operations.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_application_types_operations.py @@ -6,8 +6,9 @@ # 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, IO, Optional, TypeVar, Union, cast, overload +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,6 +18,7 @@ ResourceNotModifiedError, map_error, ) +from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod @@ -28,12 +30,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +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]] @@ -47,7 +45,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +60,7 @@ def build_get_request( "applicationTypeName": _SERIALIZER.url("application_type_name", application_type_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,8 +77,8 @@ def build_create_or_update_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", "2021-06-01")) # type: Literal["2021-06-01"] - 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", "2021-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -95,7 +93,7 @@ def build_create_or_update_request( "applicationTypeName": _SERIALIZER.url("application_type_name", application_type_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +112,7 @@ def build_delete_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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,7 +127,7 @@ def build_delete_request( "applicationTypeName": _SERIALIZER.url("application_type_name", application_type_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,7 +142,7 @@ def build_list_request(resource_group_name: str, cluster_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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -158,7 +156,7 @@ def build_list_request(resource_group_name: str, cluster_name: str, subscription "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -219,10 +217,8 @@ def get( _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationTypeResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplicationTypeResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -235,10 +231,11 @@ def get( 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 @@ -255,7 +252,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}" + } @overload def create_or_update( @@ -340,8 +339,8 @@ def create_or_update( :type cluster_name: str :param application_type_name: The name of the application type name resource. Required. :type application_type_name: str - :param parameters: The application type name resource. Is either a model type or a IO type. - Required. + :param parameters: The application type name resource. Is either a ApplicationTypeResource type + or a IO type. Required. :type parameters: ~azure.mgmt.servicefabric.models.ApplicationTypeResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -362,16 +361,14 @@ def create_or_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationTypeResource] + 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.ApplicationTypeResource] = 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, "ApplicationTypeResource") @@ -390,10 +387,11 @@ def create_or_update( 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 @@ -410,7 +408,9 @@ def create_or_update( return deserialized - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, application_type_name: str, **kwargs: Any @@ -426,10 +426,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["2021-06-01"] - 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, @@ -442,10 +440,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 @@ -458,7 +457,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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}" + } @distributed_trace def begin_delete( @@ -489,13 +490,11 @@ def begin_delete( _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["2021-06-01"] - 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, @@ -514,7 +513,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: @@ -526,12 +525,16 @@ 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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}" + } @distributed_trace - def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.ApplicationTypeResourceList: + def list( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.ApplicationTypeResource"]: """Gets the list of application type name resources created in the specified Service Fabric cluster resource. @@ -543,10 +546,17 @@ def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _m :param cluster_name: The name of the cluster resource. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationTypeResourceList or the result of cls(response) - :rtype: ~azure.mgmt.servicefabric.models.ApplicationTypeResourceList + :return: An iterator like instance of either ApplicationTypeResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicefabric.models.ApplicationTypeResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplicationTypeResourceList] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -555,42 +565,64 @@ def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _m } error_map.update(kwargs.pop("error_map", {}) or {}) - _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationTypeResourceList] - - request = build_list_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.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 - ) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationTypeResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("ApplicationTypeResourceList", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes" + } diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_applications_operations.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_applications_operations.py index 767d41969de5..a0325dbf11e4 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_applications_operations.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_applications_operations.py @@ -6,8 +6,9 @@ # 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, IO, Optional, TypeVar, Union, cast, overload +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,6 +18,7 @@ ResourceNotModifiedError, map_error, ) +from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod @@ -28,12 +30,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +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]] @@ -47,7 +45,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +60,7 @@ def build_get_request( "applicationName": _SERIALIZER.url("application_name", application_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,8 +77,8 @@ def build_create_or_update_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", "2021-06-01")) # type: Literal["2021-06-01"] - 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", "2021-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -95,7 +93,7 @@ def build_create_or_update_request( "applicationName": _SERIALIZER.url("application_name", application_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,8 +112,8 @@ def build_update_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", "2021-06-01")) # type: Literal["2021-06-01"] - 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", "2021-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,7 +128,7 @@ def build_update_request( "applicationName": _SERIALIZER.url("application_name", application_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -149,7 +147,7 @@ def build_delete_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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -164,7 +162,7 @@ def build_delete_request( "applicationName": _SERIALIZER.url("application_name", application_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -179,7 +177,7 @@ def build_list_request(resource_group_name: str, cluster_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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -193,7 +191,7 @@ def build_list_request(resource_group_name: str, cluster_name: str, subscription "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -254,10 +252,8 @@ def get( _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplicationResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -270,10 +266,11 @@ def get( 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 @@ -290,7 +287,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}" + } def _create_or_update_initial( self, @@ -311,16 +310,14 @@ def _create_or_update_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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationResource] + 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.ApplicationResource] = 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, "ApplicationResource") @@ -339,10 +336,11 @@ def _create_or_update_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 @@ -359,7 +357,9 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}" + } @overload def begin_create_or_update( @@ -460,7 +460,8 @@ def begin_create_or_update( :type cluster_name: str :param application_name: The name of the application resource. Required. :type application_name: str - :param parameters: The application resource. Is either a model type or a IO type. Required. + :param parameters: The application resource. Is either a ApplicationResource type or a IO type. + Required. :type parameters: ~azure.mgmt.servicefabric.models.ApplicationResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -481,16 +482,14 @@ def begin_create_or_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationResource] - 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.ApplicationResource] = 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_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, application_name=application_name, @@ -511,7 +510,7 @@ def get_long_running_output(pipeline_response): return deserialized 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: @@ -523,9 +522,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_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}" + } def _update_initial( self, @@ -546,16 +547,14 @@ def _update_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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationResource] + 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.ApplicationResource] = 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, "ApplicationResourceUpdate") @@ -574,10 +573,11 @@ def _update_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 @@ -594,7 +594,9 @@ def _update_initial( return deserialized - _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}" + } @overload def begin_update( @@ -695,8 +697,8 @@ def begin_update( :type cluster_name: str :param application_name: The name of the application resource. Required. :type application_name: str - :param parameters: The application resource for patch operations. Is either a model type or a - IO type. Required. + :param parameters: The application resource for patch operations. Is either a + ApplicationResourceUpdate type or a IO type. Required. :type parameters: ~azure.mgmt.servicefabric.models.ApplicationResourceUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -717,16 +719,14 @@ def begin_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationResource] - 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.ApplicationResource] = 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._update_initial( # type: ignore + raw_result = self._update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, application_name=application_name, @@ -747,7 +747,7 @@ def get_long_running_output(pipeline_response): return deserialized 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: @@ -759,9 +759,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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, application_name: str, **kwargs: Any @@ -777,10 +779,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["2021-06-01"] - 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, @@ -793,10 +793,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 @@ -809,7 +810,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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}" + } @distributed_trace def begin_delete( @@ -840,13 +843,11 @@ def begin_delete( _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["2021-06-01"] - 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, @@ -865,7 +866,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: @@ -877,12 +878,16 @@ 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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}" + } @distributed_trace - def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.ApplicationResourceList: + def list( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.ApplicationResource"]: """Gets the list of application resources created in the specified Service Fabric cluster resource. @@ -894,10 +899,16 @@ def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _m :param cluster_name: The name of the cluster resource. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationResourceList or the result of cls(response) - :rtype: ~azure.mgmt.servicefabric.models.ApplicationResourceList + :return: An iterator like instance of either ApplicationResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicefabric.models.ApplicationResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplicationResourceList] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -906,42 +917,64 @@ def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _m } error_map.update(kwargs.pop("error_map", {}) or {}) - _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationResourceList] - - request = build_list_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.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 - ) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("ApplicationResourceList", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications" + } diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_cluster_versions_operations.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_cluster_versions_operations.py index 14929a115dc8..0b913f542517 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_cluster_versions_operations.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_cluster_versions_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _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]] @@ -43,7 +38,7 @@ def build_get_request(location: str, cluster_version: str, subscription_id: str, _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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -57,7 +52,7 @@ def build_get_request(location: str, cluster_version: str, subscription_id: str, "clusterVersion": _SERIALIZER.url("cluster_version", cluster_version, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +73,7 @@ def build_get_by_environment_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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +88,7 @@ def build_get_by_environment_request( "clusterVersion": _SERIALIZER.url("cluster_version", cluster_version, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -108,7 +103,7 @@ def build_list_request(location: str, subscription_id: str, **kwargs: Any) -> Ht _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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -121,7 +116,7 @@ def build_list_request(location: str, subscription_id: str, **kwargs: Any) -> Ht "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -138,7 +133,7 @@ def build_list_by_environment_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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -152,7 +147,7 @@ def build_list_by_environment_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -210,10 +205,8 @@ def get(self, location: str, cluster_version: str, **kwargs: Any) -> _models.Clu _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterCodeVersionsListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterCodeVersionsListResult] = kwargs.pop("cls", None) request = build_get_request( location=location, @@ -225,10 +218,11 @@ def get(self, location: str, cluster_version: str, **kwargs: Any) -> _models.Clu 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 @@ -245,7 +239,9 @@ def get(self, location: str, cluster_version: str, **kwargs: Any) -> _models.Clu return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/clusterVersions/{clusterVersion}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/clusterVersions/{clusterVersion}" + } @distributed_trace def get_by_environment( @@ -284,10 +280,8 @@ def get_by_environment( _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterCodeVersionsListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterCodeVersionsListResult] = kwargs.pop("cls", None) request = build_get_by_environment_request( location=location, @@ -300,10 +294,11 @@ def get_by_environment( 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 @@ -320,7 +315,9 @@ def get_by_environment( return deserialized - get_by_environment.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/environments/{environment}/clusterVersions/{clusterVersion}"} # type: ignore + get_by_environment.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/environments/{environment}/clusterVersions/{clusterVersion}" + } @distributed_trace def list(self, location: str, **kwargs: Any) -> _models.ClusterCodeVersionsListResult: @@ -347,10 +344,8 @@ def list(self, location: str, **kwargs: Any) -> _models.ClusterCodeVersionsListR _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterCodeVersionsListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterCodeVersionsListResult] = kwargs.pop("cls", None) request = build_list_request( location=location, @@ -361,10 +356,11 @@ def list(self, location: str, **kwargs: Any) -> _models.ClusterCodeVersionsListR 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 @@ -381,7 +377,9 @@ def list(self, location: str, **kwargs: Any) -> _models.ClusterCodeVersionsListR return deserialized - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/clusterVersions"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/clusterVersions" + } @distributed_trace def list_by_environment( @@ -413,10 +411,8 @@ def list_by_environment( _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterCodeVersionsListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterCodeVersionsListResult] = kwargs.pop("cls", None) request = build_list_by_environment_request( location=location, @@ -428,10 +424,11 @@ def list_by_environment( 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 @@ -448,4 +445,6 @@ def list_by_environment( return deserialized - list_by_environment.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/environments/{environment}/clusterVersions"} # type: ignore + list_by_environment.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/environments/{environment}/clusterVersions" + } diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_clusters_operations.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_clusters_operations.py index 4ec747c4e9d6..036a5c502cea 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_clusters_operations.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_clusters_operations.py @@ -6,8 +6,9 @@ # 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, IO, Optional, TypeVar, Union, cast, overload +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,6 +18,7 @@ ResourceNotModifiedError, map_error, ) +from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod @@ -28,12 +30,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +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 +43,7 @@ def build_get_request(resource_group_name: str, cluster_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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +57,7 @@ def build_get_request(resource_group_name: str, cluster_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,8 +74,8 @@ def build_create_or_update_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", "2021-06-01")) # type: Literal["2021-06-01"] - 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", "2021-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,7 +89,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -110,8 +108,8 @@ def build_update_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", "2021-06-01")) # type: Literal["2021-06-01"] - 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", "2021-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -125,7 +123,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,7 +142,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -158,7 +156,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -173,7 +171,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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +184,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 = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -201,7 +199,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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -210,7 +208,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 = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -227,8 +225,8 @@ def build_list_upgradable_versions_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", "2021-06-01")) # type: Literal["2021-06-01"] - 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", "2021-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -242,7 +240,7 @@ def build_list_upgradable_versions_request( "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -301,10 +299,8 @@ def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _mo _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -316,10 +312,11 @@ def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _mo 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 @@ -336,7 +333,9 @@ def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _mo return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}" + } def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, parameters: Union[_models.Cluster, IO], **kwargs: Any @@ -352,16 +351,14 @@ def _create_or_update_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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + 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.Cluster] = 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, "Cluster") @@ -379,10 +376,11 @@ def _create_or_update_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 @@ -399,11 +397,13 @@ def _create_or_update_initial( deserialized = self._deserialize("Cluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}" + } @overload def begin_create_or_update( @@ -489,7 +489,7 @@ def begin_create_or_update( :type resource_group_name: str :param cluster_name: The name of the cluster resource. Required. :type cluster_name: str - :param parameters: The cluster resource. Is either a model type or a IO type. Required. + :param parameters: The cluster resource. Is either a Cluster type or a IO type. Required. :type parameters: ~azure.mgmt.servicefabric.models.Cluster or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -509,16 +509,14 @@ def begin_create_or_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] - 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.Cluster] = 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_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, @@ -538,7 +536,7 @@ def get_long_running_output(pipeline_response): return deserialized 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: @@ -550,9 +548,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_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}" + } def _update_initial( self, @@ -572,16 +572,14 @@ def _update_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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + 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.Cluster] = 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, "ClusterUpdateParameters") @@ -599,10 +597,11 @@ def _update_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 @@ -619,11 +618,13 @@ def _update_initial( deserialized = self._deserialize("Cluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}" + } @overload def begin_update( @@ -716,7 +717,8 @@ def begin_update( :param cluster_name: The name of the cluster resource. Required. :type cluster_name: str :param parameters: The parameters which contains the property value and property name which - used to update the cluster configuration. Is either a model type or a IO type. Required. + used to update the cluster configuration. Is either a ClusterUpdateParameters type or a IO + type. Required. :type parameters: ~azure.mgmt.servicefabric.models.ClusterUpdateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -736,16 +738,14 @@ def begin_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] - 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.Cluster] = 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._update_initial( # type: ignore + raw_result = self._update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, @@ -765,7 +765,7 @@ def get_long_running_output(pipeline_response): return deserialized 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: @@ -777,9 +777,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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -809,10 +811,8 @@ def delete( # 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["2021-06-01"] - 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, @@ -824,10 +824,11 @@ def delete( # 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 @@ -840,10 +841,12 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}" + } @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> _models.ClusterListResult: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Cluster"]: """Gets the list of Service Fabric cluster resources created in the specified resource group. Gets all Service Fabric cluster resources created or in the process of being created in the @@ -852,10 +855,16 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> _mo :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterListResult or the result of cls(response) - :rtype: ~azure.mgmt.servicefabric.models.ClusterListResult + :return: An iterator like instance of either Cluster or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicefabric.models.Cluster] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -864,57 +873,85 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> _mo } error_map.update(kwargs.pop("error_map", {}) or {}) - _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterListResult] + def prepare_request(next_link=None): + if not next_link: - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("ClusterListResult", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters" + } @distributed_trace - def list(self, **kwargs: Any) -> _models.ClusterListResult: + def list(self, **kwargs: Any) -> Iterable["_models.Cluster"]: """Gets the list of Service Fabric cluster resources created in the specified subscription. Gets all Service Fabric cluster resources created or in the process of being created in the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterListResult or the result of cls(response) - :rtype: ~azure.mgmt.servicefabric.models.ClusterListResult + :return: An iterator like instance of either Cluster or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicefabric.models.Cluster] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -923,43 +960,63 @@ def list(self, **kwargs: Any) -> _models.ClusterListResult: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterListResult] + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.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 - ) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("ClusterListResult", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/clusters"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/clusters"} @overload def list_upgradable_versions( @@ -1047,7 +1104,7 @@ def list_upgradable_versions( :param cluster_name: The name of the cluster resource. Required. :type cluster_name: str :param versions_description: The upgrade path description with target version. Is either a - model type or a IO type. Default value is None. + UpgradableVersionsDescription type or a IO type. Default value is None. :type versions_description: ~azure.mgmt.servicefabric.models.UpgradableVersionsDescription or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1069,16 +1126,14 @@ def list_upgradable_versions( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.UpgradableVersionPathResult] + 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.UpgradableVersionPathResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(versions_description, (IO, bytes)): + if isinstance(versions_description, (IOBase, bytes)): _content = versions_description else: if versions_description is not None: @@ -1099,10 +1154,11 @@ def list_upgradable_versions( 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 @@ -1119,4 +1175,6 @@ def list_upgradable_versions( return deserialized - list_upgradable_versions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/listUpgradableVersions"} # type: ignore + list_upgradable_versions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/listUpgradableVersions" + } diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_operations.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_operations.py index 521d2db40062..ccd1cd33a51a 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_operations.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,10 +88,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.OperationResult"]: _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -116,7 +109,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 @@ -132,7 +125,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 @@ -140,14 +133,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", 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 @@ -160,4 +154,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.ServiceFabric/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceFabric/operations"} diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_services_operations.py b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_services_operations.py index d348557766fc..b63d78573e71 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_services_operations.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/azure/mgmt/servicefabric/operations/_services_operations.py @@ -6,8 +6,9 @@ # 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, IO, Optional, TypeVar, Union, cast, overload +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,6 +18,7 @@ ResourceNotModifiedError, map_error, ) +from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod @@ -28,12 +30,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +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]] @@ -52,7 +50,7 @@ def build_get_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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +66,7 @@ def build_get_request( "serviceName": _SERIALIZER.url("service_name", service_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,8 +88,8 @@ def build_create_or_update_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", "2021-06-01")) # type: Literal["2021-06-01"] - 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", "2021-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +105,7 @@ def build_create_or_update_request( "serviceName": _SERIALIZER.url("service_name", service_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -131,8 +129,8 @@ def build_update_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", "2021-06-01")) # type: Literal["2021-06-01"] - 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", "2021-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -148,7 +146,7 @@ def build_update_request( "serviceName": _SERIALIZER.url("service_name", service_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -172,7 +170,7 @@ def build_delete_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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,7 +186,7 @@ def build_delete_request( "serviceName": _SERIALIZER.url("service_name", service_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -205,7 +203,7 @@ def build_list_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", "2021-06-01")) # type: Literal["2021-06-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -220,7 +218,7 @@ def build_list_request( "applicationName": _SERIALIZER.url("application_name", application_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -284,10 +282,8 @@ def get( _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServiceResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -301,10 +297,11 @@ def get( 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 @@ -321,7 +318,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}" + } def _create_or_update_initial( self, @@ -343,16 +342,14 @@ def _create_or_update_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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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.ServiceResource] = 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, "ServiceResource") @@ -372,10 +369,11 @@ def _create_or_update_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 @@ -392,7 +390,9 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}" + } @overload def begin_create_or_update( @@ -505,7 +505,8 @@ def begin_create_or_update( :param service_name: The name of the service resource in the format of {applicationName}~{serviceName}. Required. :type service_name: str - :param parameters: The service resource. Is either a model type or a IO type. Required. + :param parameters: The service resource. Is either a ServiceResource type or a IO type. + Required. :type parameters: ~azure.mgmt.servicefabric.models.ServiceResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -526,16 +527,14 @@ def begin_create_or_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - 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.ServiceResource] = 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_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, application_name=application_name, @@ -557,7 +556,7 @@ def get_long_running_output(pipeline_response): return deserialized 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: @@ -569,9 +568,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_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}" + } def _update_initial( self, @@ -593,16 +594,14 @@ def _update_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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + 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.ServiceResource] = 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, "ServiceResourceUpdate") @@ -622,10 +621,11 @@ def _update_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 @@ -642,7 +642,9 @@ def _update_initial( return deserialized - _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}" + } @overload def begin_update( @@ -755,8 +757,8 @@ def begin_update( :param service_name: The name of the service resource in the format of {applicationName}~{serviceName}. Required. :type service_name: str - :param parameters: The service resource for patch operations. Is either a model type or a IO - type. Required. + :param parameters: The service resource for patch operations. Is either a ServiceResourceUpdate + type or a IO type. Required. :type parameters: ~azure.mgmt.servicefabric.models.ServiceResourceUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -777,16 +779,14 @@ def begin_update( _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["2021-06-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - 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.ServiceResource] = 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._update_initial( # type: ignore + raw_result = self._update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, application_name=application_name, @@ -808,7 +808,7 @@ def get_long_running_output(pipeline_response): return deserialized 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: @@ -820,9 +820,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_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, application_name: str, service_name: str, **kwargs: Any @@ -838,10 +840,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["2021-06-01"] - 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, @@ -855,10 +855,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 @@ -871,7 +872,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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}" + } @distributed_trace def begin_delete( @@ -905,13 +908,11 @@ def begin_delete( _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["2021-06-01"] - 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, @@ -931,7 +932,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: @@ -943,14 +944,16 @@ 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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}" + } @distributed_trace def list( self, resource_group_name: str, cluster_name: str, application_name: str, **kwargs: Any - ) -> _models.ServiceResourceList: + ) -> Iterable["_models.ServiceResource"]: """Gets the list of service resources created in the specified Service Fabric application resource. @@ -964,10 +967,16 @@ def list( :param application_name: The name of the application resource. Required. :type application_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResourceList or the result of cls(response) - :rtype: ~azure.mgmt.servicefabric.models.ServiceResourceList + :return: An iterator like instance of either ServiceResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicefabric.models.ServiceResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServiceResourceList] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -976,43 +985,65 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - _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["2021-06-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceList] - - request = build_list_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.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 - ) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("ServiceResourceList", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorModel, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services" + } diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_an_application.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_delete_operation_example.py similarity index 93% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_an_application.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_delete_operation_example.py index 023f2a25df6c..e4e2a606563f 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_an_application.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_delete_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python delete_an_application.py + python application_delete_operation_example.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,12 +29,11 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.applications.begin_delete( + client.applications.begin_delete( resource_group_name="resRg", cluster_name="myCluster", application_name="myApp", ).result() - print(response) # x-ms-original-file: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationDeleteOperation_example.json diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_an_application.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_get_operation_example.py similarity index 97% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_an_application.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_get_operation_example.py index 6ffb8ee51ae3..b8ce6c7ba85a 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_an_application.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_get_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python get_an_application.py + python application_get_operation_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_list_of_application_resources.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_list_operation_example.py similarity index 94% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_list_of_application_resources.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_list_operation_example.py index 364dd39f7263..4375fa80ee54 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_list_of_application_resources.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_list_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python get_a_list_of_application_resources.py + python application_list_operation_example.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, @@ -33,7 +33,8 @@ def main(): resource_group_name="resRg", cluster_name="myCluster", ) - print(response) + for item in response: + print(item) # x-ms-original-file: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationListOperation_example.json diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/patch_an_application.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_patch_operation_example.py similarity index 97% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/patch_an_application.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_patch_operation_example.py index b115f548ab8c..0dce7a3cbb7c 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/patch_an_application.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_patch_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python patch_an_application.py + python application_patch_operation_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_with_maximum_parameters.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_put_operation_example_max.py similarity index 98% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_with_maximum_parameters.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_put_operation_example_max.py index b592ef46bb45..e94cd873cd36 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_with_maximum_parameters.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_put_operation_example_max.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python put_an_application_with_maximum_parameters.py + python application_put_operation_example_max.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_with_minimum_parameters.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_put_operation_example_min.py similarity index 96% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_with_minimum_parameters.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_put_operation_example_min.py index 80d944232748..72c6304551b8 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_with_minimum_parameters.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_put_operation_example_min.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python put_an_application_with_minimum_parameters.py + python application_put_operation_example_min.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_with_recreate_option.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_put_operation_recreate_example.py similarity index 97% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_with_recreate_option.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_put_operation_recreate_example.py index af7b717ea162..b607aeaa274d 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_with_recreate_option.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_put_operation_recreate_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python put_an_application_with_recreate_option.py + python application_put_operation_recreate_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_an_application_type.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_name_delete_operation_example.py similarity index 93% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_an_application_type.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_name_delete_operation_example.py index 32c4415b5e13..352a2018daf6 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_an_application_type.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_name_delete_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python delete_an_application_type.py + python application_type_name_delete_operation_example.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,12 +29,11 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.application_types.begin_delete( + client.application_types.begin_delete( resource_group_name="resRg", cluster_name="myCluster", application_type_name="myAppType", ).result() - print(response) # x-ms-original-file: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeNameDeleteOperation_example.json diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_an_application_type.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_name_get_operation_example.py similarity index 96% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_an_application_type.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_name_get_operation_example.py index 7e25bcb3c0e7..62ebe1b4cb51 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_an_application_type.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_name_get_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python get_an_application_type.py + python application_type_name_get_operation_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_list_of_application_type_name_resources.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_name_list_operation_example.py similarity index 93% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_list_of_application_type_name_resources.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_name_list_operation_example.py index c8e23fba8e56..648be004a7dc 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_list_of_application_type_name_resources.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_name_list_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python get_a_list_of_application_type_name_resources.py + python application_type_name_list_operation_example.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, @@ -33,7 +33,8 @@ def main(): resource_group_name="resRg", cluster_name="myCluster", ) - print(response) + for item in response: + print(item) # x-ms-original-file: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeNameListOperation_example.json diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_type.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_name_put_operation_example.py similarity index 96% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_type.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_name_put_operation_example.py index 2e3f51218596..a69f63397e05 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_type.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_name_put_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python put_an_application_type.py + python application_type_name_put_operation_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_an_application_type_version.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_version_delete_operation_example.py similarity index 92% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_an_application_type_version.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_version_delete_operation_example.py index 2ff80bc57da0..c6376b6ea078 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_an_application_type_version.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_version_delete_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python delete_an_application_type_version.py + python application_type_version_delete_operation_example.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="00000000-0000-0000-0000-000000000000", ) - response = client.application_type_versions.begin_delete( + client.application_type_versions.begin_delete( resource_group_name="resRg", cluster_name="myCluster", application_type_name="myAppType", version="1.0", ).result() - print(response) # x-ms-original-file: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeVersionDeleteOperation_example.json diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_an_application_type_version.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_version_get_operation_example.py similarity index 96% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_an_application_type_version.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_version_get_operation_example.py index 0eb0a6c9ecce..60be0ea36579 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_an_application_type_version.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_version_get_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python get_an_application_type_version.py + python application_type_version_get_operation_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_list_of_application_type_version_resources.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_version_list_operation_example.py similarity index 93% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_list_of_application_type_version_resources.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_version_list_operation_example.py index 90355c3331de..aa1b0cc954e9 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_list_of_application_type_version_resources.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_version_list_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python get_a_list_of_application_type_version_resources.py + python application_type_version_list_operation_example.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, @@ -34,7 +34,8 @@ def main(): cluster_name="myCluster", application_type_name="myAppType", ) - print(response) + for item in response: + print(item) # x-ms-original-file: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeVersionListOperation_example.json diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_type_version.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_version_put_operation_example.py similarity index 96% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_type_version.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_version_put_operation_example.py index f29a21d8ff9f..4279eb432f88 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_an_application_type_version.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/application_type_version_put_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python put_an_application_type_version.py + python application_type_version_put_operation_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_a_cluster.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_delete_operation_example.py similarity index 94% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_a_cluster.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_delete_operation_example.py index 1be52db4a4dc..cd7ef34ce423 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_a_cluster.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_delete_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python delete_a_cluster.py + python cluster_delete_operation_example.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,11 +29,10 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.clusters.delete( + client.clusters.delete( resource_group_name="resRg", cluster_name="myCluster", ) - print(response) # x-ms-original-file: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterDeleteOperation_example.json diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_cluster.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_get_operation_example.py similarity index 97% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_cluster.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_get_operation_example.py index 9ae8afca5435..33fded8ef7a4 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_cluster.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_get_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python get_a_cluster.py + python cluster_get_operation_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_cluster_by_resource_group.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_list_by_resource_group_operation_example.py similarity index 93% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_cluster_by_resource_group.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_list_by_resource_group_operation_example.py index 22bc4a92da3d..26ceabea5df6 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_cluster_by_resource_group.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_list_by_resource_group_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python list_cluster_by_resource_group.py + python cluster_list_by_resource_group_operation_example.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, @@ -32,7 +32,8 @@ def main(): response = client.clusters.list_by_resource_group( resource_group_name="resRg", ) - print(response) + for item in response: + print(item) # x-ms-original-file: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterListByResourceGroupOperation_example.json diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_clusters.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_list_operation_example.py similarity index 94% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_clusters.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_list_operation_example.py index 6b3a0ec75a76..d2d3c5d23ea0 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_clusters.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_list_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python list_clusters.py + python cluster_list_operation_example.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, @@ -30,7 +30,8 @@ def main(): ) response = client.clusters.list() - print(response) + for item in response: + print(item) # x-ms-original-file: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterListOperation_example.json diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/patch_a_cluster.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_patch_operation_example.py similarity index 98% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/patch_a_cluster.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_patch_operation_example.py index 8b0227977d2f..17ea56193104 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/patch_a_cluster.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_patch_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python patch_a_cluster.py + python cluster_patch_operation_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_a_cluster_with_maximum_parameters.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_put_operation_example_max.py similarity index 99% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_a_cluster_with_maximum_parameters.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_put_operation_example_max.py index 038eec663174..9f64a3b7d7e3 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_a_cluster_with_maximum_parameters.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_put_operation_example_max.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python put_a_cluster_with_maximum_parameters.py + python cluster_put_operation_example_max.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_a_cluster_with_minimum_parameters.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_put_operation_example_min.py similarity index 98% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_a_cluster_with_minimum_parameters.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_put_operation_example_min.py index eed6522f9308..4c281deb8807 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_a_cluster_with_minimum_parameters.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_put_operation_example_min.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python put_a_cluster_with_minimum_parameters.py + python cluster_put_operation_example_min.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_cluster_version_by_environment.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_versions_get_by_environment_example.py similarity index 96% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_cluster_version_by_environment.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_versions_get_by_environment_example.py index 6d4e0cda403f..bf5c8e400fb3 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_cluster_version_by_environment.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_versions_get_by_environment_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python get_cluster_version_by_environment.py + python cluster_versions_get_by_environment_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_cluster_version.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_versions_get_example.py similarity index 97% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_cluster_version.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_versions_get_example.py index dfdc0a7e14ac..91bf33ee61b9 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_cluster_version.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_versions_get_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python get_cluster_version.py + python cluster_versions_get_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_cluster_versions_by_environment.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_versions_list_by_environment.py similarity index 96% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_cluster_versions_by_environment.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_versions_list_by_environment.py index ed4706b6b73d..997667ddb236 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_cluster_versions_by_environment.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_versions_list_by_environment.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python list_cluster_versions_by_environment.py + python cluster_versions_list_by_environment.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_cluster_versions.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_versions_list_example.py similarity index 97% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_cluster_versions.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_versions_list_example.py index 26a8c516fa35..ed0e4c3f70bc 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_cluster_versions.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/cluster_versions_list_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python list_cluster_versions.py + python cluster_versions_list_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_minimum_and_maximum_code_versions.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_upgradable_versions_min_max_example.py similarity index 96% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_minimum_and_maximum_code_versions.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_upgradable_versions_min_max_example.py index df57f625f802..295e5304dda2 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_minimum_and_maximum_code_versions.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_upgradable_versions_min_max_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python get_minimum_and_maximum_code_versions.py + python list_upgradable_versions_min_max_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_upgrade_path.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_upgradable_versions_path_example.py similarity index 96% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_upgrade_path.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_upgradable_versions_path_example.py index ee95544467ac..17fee0c68193 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_upgrade_path.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/list_upgradable_versions_path_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python get_upgrade_path.py + python list_upgradable_versions_path_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_a_service.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_delete_operation_example.py similarity index 94% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_a_service.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_delete_operation_example.py index d9a85897d337..7eea9e7fc5b3 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/delete_a_service.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_delete_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python delete_a_service.py + python service_delete_operation_example.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="00000000-0000-0000-0000-000000000000", ) - response = client.services.begin_delete( + client.services.begin_delete( resource_group_name="resRg", cluster_name="myCluster", application_name="myApp", service_name="myService", ).result() - print(response) # x-ms-original-file: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ServiceDeleteOperation_example.json diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_service.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_get_operation_example.py similarity index 97% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_service.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_get_operation_example.py index 9021133d080c..2760cec6fbb7 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_service.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_get_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python get_a_service.py + python service_get_operation_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_list_of_service_resources.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_list_operation_example.py similarity index 94% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_list_of_service_resources.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_list_operation_example.py index 2f34e89984aa..f7820e610e9b 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/get_a_list_of_service_resources.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_list_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python get_a_list_of_service_resources.py + python service_list_operation_example.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, @@ -34,7 +34,8 @@ def main(): cluster_name="myCluster", application_name="myApp", ) - print(response) + for item in response: + print(item) # x-ms-original-file: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ServiceListOperation_example.json diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/patch_a_service.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_patch_operation_example.py similarity index 97% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/patch_a_service.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_patch_operation_example.py index 984c8ccc5cd6..61277b98cba1 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/patch_a_service.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_patch_operation_example.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python patch_a_service.py + python service_patch_operation_example.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_a_service_with_maximum_parameters.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_put_operation_example_max.py similarity index 97% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_a_service_with_maximum_parameters.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_put_operation_example_max.py index 77e437ed5817..ec402c63dca0 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_a_service_with_maximum_parameters.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_put_operation_example_max.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python put_a_service_with_maximum_parameters.py + python service_put_operation_example_max.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, diff --git a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_a_service_with_minimum_parameters.py b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_put_operation_example_min.py similarity index 97% rename from sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_a_service_with_minimum_parameters.py rename to sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_put_operation_example_min.py index 4c68e3700567..d59d6c57de69 100644 --- a/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/put_a_service_with_minimum_parameters.py +++ b/sdk/servicefabric/azure-mgmt-servicefabric/generated_samples/service_put_operation_example_min.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-servicefabric # USAGE - python put_a_service_with_minimum_parameters.py + python service_put_operation_example_min.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,